Updated ProgressIndicator
to M3 (#112139)
This commit is contained in:
parent
71c21d60c1
commit
e167162830
@ -31,6 +31,7 @@ import 'package:gen_defaults/input_chip_template.dart';
|
|||||||
import 'package:gen_defaults/input_decorator_template.dart';
|
import 'package:gen_defaults/input_decorator_template.dart';
|
||||||
import 'package:gen_defaults/navigation_bar_template.dart';
|
import 'package:gen_defaults/navigation_bar_template.dart';
|
||||||
import 'package:gen_defaults/navigation_rail_template.dart';
|
import 'package:gen_defaults/navigation_rail_template.dart';
|
||||||
|
import 'package:gen_defaults/progress_indicator_template.dart';
|
||||||
import 'package:gen_defaults/radio_template.dart';
|
import 'package:gen_defaults/radio_template.dart';
|
||||||
import 'package:gen_defaults/surface_tint.dart';
|
import 'package:gen_defaults/surface_tint.dart';
|
||||||
import 'package:gen_defaults/switch_template.dart';
|
import 'package:gen_defaults/switch_template.dart';
|
||||||
@ -80,6 +81,8 @@ Future<void> main(List<String> args) async {
|
|||||||
'navigation_drawer.json',
|
'navigation_drawer.json',
|
||||||
'navigation_rail.json',
|
'navigation_rail.json',
|
||||||
'palette.json',
|
'palette.json',
|
||||||
|
'progress_indicator_circular.json',
|
||||||
|
'progress_indicator_linear.json',
|
||||||
'radio_button.json',
|
'radio_button.json',
|
||||||
'segmented_button_outlined.json',
|
'segmented_button_outlined.json',
|
||||||
'shape.json',
|
'shape.json',
|
||||||
@ -126,6 +129,7 @@ Future<void> main(List<String> args) async {
|
|||||||
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
|
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
|
||||||
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
|
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
|
||||||
NavigationRailTemplate('NavigationRail', '$materialLib/navigation_rail.dart', tokens).updateFile();
|
NavigationRailTemplate('NavigationRail', '$materialLib/navigation_rail.dart', tokens).updateFile();
|
||||||
|
ProgressIndicatorTemplate('ProgressIndicator', '$materialLib/progress_indicator.dart', tokens).updateFile();
|
||||||
RadioTemplate('Radio<T>', '$materialLib/radio.dart', tokens).updateFile();
|
RadioTemplate('Radio<T>', '$materialLib/radio.dart', tokens).updateFile();
|
||||||
SurfaceTintTemplate('SurfaceTint', '$materialLib/elevation_overlay.dart', tokens).updateFile();
|
SurfaceTintTemplate('SurfaceTint', '$materialLib/elevation_overlay.dart', tokens).updateFile();
|
||||||
SwitchTemplate('Switch', '$materialLib/switch.dart', tokens).updateFile();
|
SwitchTemplate('Switch', '$materialLib/switch.dart', tokens).updateFile();
|
||||||
|
42
dev/tools/gen_defaults/lib/progress_indicator_template.dart
Normal file
42
dev/tools/gen_defaults/lib/progress_indicator_template.dart
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'template.dart';
|
||||||
|
|
||||||
|
class ProgressIndicatorTemplate extends TokenTemplate {
|
||||||
|
const ProgressIndicatorTemplate(super.blockName, super.fileName, super.tokens, {
|
||||||
|
super.colorSchemePrefix = '_colors.',
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
String generate() => '''
|
||||||
|
class _Circular${blockName}DefaultsM3 extends ProgressIndicatorThemeData {
|
||||||
|
_Circular${blockName}DefaultsM3(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
static const double circularProgressIndicatorSize = ${tokens['md.comp.circular-progress-indicator.size']};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => ${componentColor('md.comp.circular-progress-indicator.active-indicator')};
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Linear${blockName}DefaultsM3 extends ProgressIndicatorThemeData {
|
||||||
|
_Linear${blockName}DefaultsM3(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => ${componentColor('md.comp.linear-progress-indicator.active-indicator')};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get linearTrackColor => ${componentColor('md.comp.linear-progress-indicator.track')};
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get linearMinHeight => ${tokens['md.comp.linear-progress-indicator.track.height']};
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
}
|
@ -108,11 +108,11 @@ abstract class ProgressIndicator extends StatefulWidget {
|
|||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
final String? semanticsValue;
|
final String? semanticsValue;
|
||||||
|
|
||||||
Color _getValueColor(BuildContext context) {
|
Color _getValueColor(BuildContext context, {Color? defaultColor}) {
|
||||||
return
|
return valueColor?.value ??
|
||||||
valueColor?.value ??
|
|
||||||
color ??
|
color ??
|
||||||
ProgressIndicatorTheme.of(context).color ??
|
ProgressIndicatorTheme.of(context).color ??
|
||||||
|
defaultColor ??
|
||||||
Theme.of(context).colorScheme.primary;
|
Theme.of(context).colorScheme.primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,12 +331,17 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIndicator(BuildContext context, double animationValue, TextDirection textDirection) {
|
Widget _buildIndicator(BuildContext context, double animationValue, TextDirection textDirection) {
|
||||||
|
final ProgressIndicatorThemeData defaults = Theme.of(context).useMaterial3
|
||||||
|
? _LinearProgressIndicatorDefaultsM3(context)
|
||||||
|
: _LinearProgressIndicatorDefaultsM2(context);
|
||||||
|
|
||||||
final ProgressIndicatorThemeData indicatorTheme = ProgressIndicatorTheme.of(context);
|
final ProgressIndicatorThemeData indicatorTheme = ProgressIndicatorTheme.of(context);
|
||||||
final Color trackColor =
|
final Color trackColor = widget.backgroundColor ??
|
||||||
widget.backgroundColor ??
|
|
||||||
indicatorTheme.linearTrackColor ??
|
indicatorTheme.linearTrackColor ??
|
||||||
Theme.of(context).colorScheme.background;
|
defaults.linearTrackColor!;
|
||||||
final double minHeight = widget.minHeight ?? indicatorTheme.linearMinHeight ?? 4.0;
|
final double minHeight = widget.minHeight ??
|
||||||
|
indicatorTheme.linearMinHeight ??
|
||||||
|
defaults.linearMinHeight!;
|
||||||
|
|
||||||
return widget._buildSemanticsWrapper(
|
return widget._buildSemanticsWrapper(
|
||||||
context: context,
|
context: context,
|
||||||
@ -348,7 +353,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
|
|||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: _LinearProgressIndicatorPainter(
|
painter: _LinearProgressIndicatorPainter(
|
||||||
backgroundColor: trackColor,
|
backgroundColor: trackColor,
|
||||||
valueColor: widget._getValueColor(context),
|
valueColor: widget._getValueColor(context, defaultColor: defaults.color),
|
||||||
value: widget.value, // may be null
|
value: widget.value, // may be null
|
||||||
animationValue: animationValue, // ignored if widget.value is not null
|
animationValue: animationValue, // ignored if widget.value is not null
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
@ -580,11 +585,12 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMaterialIndicator(BuildContext context, double headValue, double tailValue, double offsetValue, double rotationValue) {
|
Widget _buildMaterialIndicator(BuildContext context, double headValue, double tailValue, double offsetValue, double rotationValue) {
|
||||||
|
final ProgressIndicatorThemeData defaults = Theme.of(context).useMaterial3
|
||||||
|
? _CircularProgressIndicatorDefaultsM3(context)
|
||||||
|
: _CircularProgressIndicatorDefaultsM2(context);
|
||||||
final Color? trackColor = widget.backgroundColor ?? ProgressIndicatorTheme.of(context).circularTrackColor;
|
final Color? trackColor = widget.backgroundColor ?? ProgressIndicatorTheme.of(context).circularTrackColor;
|
||||||
|
|
||||||
return widget._buildSemanticsWrapper(
|
Widget progressIndicator = Container(
|
||||||
context: context,
|
|
||||||
child: Container(
|
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minWidth: _kMinCircularProgressIndicatorSize,
|
minWidth: _kMinCircularProgressIndicatorSize,
|
||||||
minHeight: _kMinCircularProgressIndicatorSize,
|
minHeight: _kMinCircularProgressIndicatorSize,
|
||||||
@ -592,7 +598,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
|
|||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: _CircularProgressIndicatorPainter(
|
painter: _CircularProgressIndicatorPainter(
|
||||||
backgroundColor: trackColor,
|
backgroundColor: trackColor,
|
||||||
valueColor: widget._getValueColor(context),
|
valueColor: widget._getValueColor(context, defaultColor: defaults.color),
|
||||||
value: widget.value, // may be null
|
value: widget.value, // may be null
|
||||||
headValue: headValue, // remaining arguments are ignored if widget.value is not null
|
headValue: headValue, // remaining arguments are ignored if widget.value is not null
|
||||||
tailValue: tailValue,
|
tailValue: tailValue,
|
||||||
@ -601,10 +607,24 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
|
|||||||
strokeWidth: widget.strokeWidth,
|
strokeWidth: widget.strokeWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Theme.of(context).useMaterial3) {
|
||||||
|
progressIndicator = SizedBox(
|
||||||
|
height: _CircularProgressIndicatorDefaultsM3.circularProgressIndicatorSize,
|
||||||
|
width: _CircularProgressIndicatorDefaultsM3.circularProgressIndicatorSize,
|
||||||
|
child: Center(
|
||||||
|
child: progressIndicator
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return widget._buildSemanticsWrapper(
|
||||||
|
context: context,
|
||||||
|
child: progressIndicator,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildAnimation() {
|
Widget _buildAnimation() {
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: _controller,
|
animation: _controller,
|
||||||
@ -866,3 +886,69 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hand coded defaults based on Material Design 2.
|
||||||
|
class _CircularProgressIndicatorDefaultsM2 extends ProgressIndicatorThemeData {
|
||||||
|
_CircularProgressIndicatorDefaultsM2(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => _colors.primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LinearProgressIndicatorDefaultsM2 extends ProgressIndicatorThemeData {
|
||||||
|
_LinearProgressIndicatorDefaultsM2(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => _colors.primary;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get linearTrackColor => _colors.background;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get linearMinHeight => 4.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BEGIN GENERATED TOKEN PROPERTIES - ProgressIndicator
|
||||||
|
|
||||||
|
// Do not edit by hand. The code between the "BEGIN GENERATED" and
|
||||||
|
// "END GENERATED" comments are generated from data in the Material
|
||||||
|
// Design token database by the script:
|
||||||
|
// dev/tools/gen_defaults/bin/gen_defaults.dart.
|
||||||
|
|
||||||
|
// Token database version: v0_132
|
||||||
|
|
||||||
|
class _CircularProgressIndicatorDefaultsM3 extends ProgressIndicatorThemeData {
|
||||||
|
_CircularProgressIndicatorDefaultsM3(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
static const double circularProgressIndicatorSize = 48.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => _colors.primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LinearProgressIndicatorDefaultsM3 extends ProgressIndicatorThemeData {
|
||||||
|
_LinearProgressIndicatorDefaultsM3(this.context);
|
||||||
|
|
||||||
|
final BuildContext context;
|
||||||
|
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get color => _colors.primary;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get linearTrackColor => _colors.surfaceVariant;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get linearMinHeight => 4.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// END GENERATED TOKEN PROPERTIES - ProgressIndicator
|
||||||
|
@ -1266,6 +1266,7 @@ class ThemeData with Diagnosticable {
|
|||||||
/// * Lists: [ListTile]
|
/// * Lists: [ListTile]
|
||||||
/// * Navigation bar: [NavigationBar] (new, replacing [BottomNavigationBar])
|
/// * Navigation bar: [NavigationBar] (new, replacing [BottomNavigationBar])
|
||||||
/// * [Navigation rail](https://m3.material.io/components/navigation-rail): [NavigationRail]
|
/// * [Navigation rail](https://m3.material.io/components/navigation-rail): [NavigationRail]
|
||||||
|
/// * Progress indicators: [CircularProgressIndicator], [LinearProgressIndicator]
|
||||||
/// * Radio button: [Radio]
|
/// * Radio button: [Radio]
|
||||||
/// * Switch: [Switch]
|
/// * Switch: [Switch]
|
||||||
/// * Top app bar: [AppBar]
|
/// * Top app bar: [AppBar]
|
||||||
|
@ -20,6 +20,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
final ThemeData theme = ThemeData();
|
||||||
|
|
||||||
// The "can be constructed" tests that follow are primarily to ensure that any
|
// The "can be constructed" tests that follow are primarily to ensure that any
|
||||||
// animations started by the progress indicators are stopped at dispose() time.
|
// animations started by the progress indicators are stopped at dispose() time.
|
||||||
@ -27,7 +28,9 @@ void main() {
|
|||||||
testWidgets('LinearProgressIndicator(value: 0.0) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator(value: 0.0) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -36,6 +39,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
|
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
|
||||||
@ -45,7 +49,9 @@ void main() {
|
|||||||
testWidgets('LinearProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -54,6 +60,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
|
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
|
||||||
@ -62,7 +69,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator custom minHeight', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator custom minHeight', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -71,6 +80,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
find.byType(LinearProgressIndicator),
|
find.byType(LinearProgressIndicator),
|
||||||
@ -82,7 +92,7 @@ void main() {
|
|||||||
// Same test, but using the theme
|
// Same test, but using the theme
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
data: ThemeData(
|
data: theme.copyWith(
|
||||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
linearMinHeight: 2.0,
|
linearMinHeight: 2.0,
|
||||||
),
|
),
|
||||||
@ -108,7 +118,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator paint (LTR)', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator paint (LTR)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -117,6 +129,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -131,7 +144,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -140,6 +155,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -154,7 +170,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator indeterminate (LTR)', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator indeterminate (LTR)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -163,6 +181,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump(const Duration(milliseconds: 300));
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
@ -181,7 +200,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -190,6 +211,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump(const Duration(milliseconds: 300));
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
@ -209,7 +231,9 @@ void main() {
|
|||||||
testWidgets('LinearProgressIndicator with colors', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator with colors', (WidgetTester tester) async {
|
||||||
// With valueColor & color provided
|
// With valueColor & color provided
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -223,6 +247,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should use valueColor
|
// Should use valueColor
|
||||||
@ -235,7 +260,9 @@ void main() {
|
|||||||
|
|
||||||
// With just color provided
|
// With just color provided
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -248,6 +275,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should use color
|
// Should use color
|
||||||
@ -260,10 +288,9 @@ void main() {
|
|||||||
|
|
||||||
// With no color provided
|
// With no color provided
|
||||||
const Color primaryColor = Color(0xff008800);
|
const Color primaryColor = Color(0xff008800);
|
||||||
final ThemeData theme = ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: primaryColor));
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
data: theme,
|
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: primaryColor)),
|
||||||
child: const Directionality(
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -291,7 +318,7 @@ void main() {
|
|||||||
const Color indicatorColor = Color(0xff0000ff);
|
const Color indicatorColor = Color(0xff0000ff);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
data: ThemeData(
|
data: theme.copyWith(
|
||||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
color: indicatorColor,
|
color: indicatorColor,
|
||||||
linearTrackColor: Colors.black,
|
linearTrackColor: Colors.black,
|
||||||
@ -323,7 +350,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator with animation with null colors', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator with animation with null colors', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -336,6 +365,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -349,12 +379,15 @@ void main() {
|
|||||||
testWidgets('CircularProgressIndicator(value: 0.0) can be constructed and has value semantics by default', (WidgetTester tester) async {
|
testWidgets('CircularProgressIndicator(value: 0.0) can be constructed and has value semantics by default', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(value: 0.0),
|
child: CircularProgressIndicator(value: 0.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics(
|
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics(
|
||||||
@ -367,9 +400,12 @@ void main() {
|
|||||||
testWidgets('CircularProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
testWidgets('CircularProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Center(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics());
|
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics());
|
||||||
@ -377,25 +413,31 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.0)]),
|
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.0)]),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
final List<Layer> layers1 = tester.layers;
|
final List<Layer> layers1 = tester.layers;
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.5)]),
|
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.5)]),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
final List<Layer> layers2 = tester.layers;
|
final List<Layer> layers2 = tester.layers;
|
||||||
expect(layers1, isNot(equals(layers2)));
|
expect(layers1, isNot(equals(layers2)));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('CircularProgressIndicator stoke width', (WidgetTester tester) async {
|
testWidgets('CircularProgressIndicator stoke width', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(const CircularProgressIndicator());
|
await tester.pumpWidget(Theme(data: theme, child: const CircularProgressIndicator()));
|
||||||
|
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 4.0));
|
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 4.0));
|
||||||
|
|
||||||
await tester.pumpWidget(const CircularProgressIndicator(strokeWidth: 16.0));
|
await tester.pumpWidget(Theme(data: theme, child: const CircularProgressIndicator(strokeWidth: 16.0)));
|
||||||
|
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 16.0));
|
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 16.0));
|
||||||
});
|
});
|
||||||
@ -406,39 +448,48 @@ void main() {
|
|||||||
const Color red = Color(0xFFFF0000);
|
const Color red = Color(0xFFFF0000);
|
||||||
|
|
||||||
// With valueColor & color provided
|
// With valueColor & color provided
|
||||||
await tester.pumpWidget(const CircularProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const CircularProgressIndicator(
|
||||||
color: red,
|
color: red,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(blue),
|
valueColor: AlwaysStoppedAnimation<Color>(blue),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(color: blue));
|
expect(find.byType(CircularProgressIndicator), paints..arc(color: blue));
|
||||||
|
|
||||||
// With just color provided
|
// With just color provided
|
||||||
await tester.pumpWidget(const CircularProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const CircularProgressIndicator(
|
||||||
color: red,
|
color: red,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(color: red));
|
expect(find.byType(CircularProgressIndicator), paints..arc(color: red));
|
||||||
|
|
||||||
// With no color provided
|
// With no color provided
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
data: ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
|
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
|
||||||
child: const CircularProgressIndicator(),
|
child: const CircularProgressIndicator(),
|
||||||
));
|
));
|
||||||
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(color: green));
|
expect(find.byType(CircularProgressIndicator), paints..arc(color: green));
|
||||||
|
|
||||||
// With background
|
// With background
|
||||||
await tester.pumpWidget(const CircularProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const CircularProgressIndicator(
|
||||||
backgroundColor: green,
|
backgroundColor: green,
|
||||||
color: blue,
|
color: blue,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 2));
|
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 2));
|
||||||
expect(find.byType(CircularProgressIndicator), paints..arc(color: green)..arc(color: blue));
|
expect(find.byType(CircularProgressIndicator), paints..arc(color: green)..arc(color: blue));
|
||||||
|
|
||||||
// With ProgressIndicatorTheme
|
// With ProgressIndicatorTheme
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
data: ThemeData(progressIndicatorTheme: const ProgressIndicatorThemeData(
|
data: theme.copyWith(progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
color: green,
|
color: green,
|
||||||
circularTrackColor: blue,
|
circularTrackColor: blue,
|
||||||
)),
|
)),
|
||||||
@ -454,32 +505,41 @@ void main() {
|
|||||||
const Color red = Color(0xFFFF0000);
|
const Color red = Color(0xFFFF0000);
|
||||||
|
|
||||||
// With valueColor & color provided
|
// With valueColor & color provided
|
||||||
await tester.pumpWidget(const RefreshProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const RefreshProgressIndicator(
|
||||||
color: red,
|
color: red,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(blue),
|
valueColor: AlwaysStoppedAnimation<Color>(blue),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
|
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
|
||||||
|
|
||||||
// With just color provided
|
// With just color provided
|
||||||
await tester.pumpWidget(const RefreshProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const RefreshProgressIndicator(
|
||||||
color: red,
|
color: red,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(RefreshProgressIndicator), paints..arc(color: red));
|
expect(find.byType(RefreshProgressIndicator), paints..arc(color: red));
|
||||||
|
|
||||||
// With no color provided
|
// With no color provided
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
data: ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
|
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
|
||||||
child: const RefreshProgressIndicator(),
|
child: const RefreshProgressIndicator(),
|
||||||
));
|
));
|
||||||
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(RefreshProgressIndicator), paints..arc(color: green));
|
expect(find.byType(RefreshProgressIndicator), paints..arc(color: green));
|
||||||
|
|
||||||
// With background
|
// With background
|
||||||
await tester.pumpWidget(const RefreshProgressIndicator(
|
await tester.pumpWidget(Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const RefreshProgressIndicator(
|
||||||
color: blue,
|
color: blue,
|
||||||
backgroundColor: green,
|
backgroundColor: green,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
|
||||||
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
|
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
|
||||||
@ -492,7 +552,7 @@ void main() {
|
|||||||
|
|
||||||
// With ProgressIndicatorTheme
|
// With ProgressIndicatorTheme
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
data: ThemeData(progressIndicatorTheme: const ProgressIndicatorThemeData(
|
data: theme.copyWith(progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
color: green,
|
color: green,
|
||||||
refreshBackgroundColor: blue,
|
refreshBackgroundColor: blue,
|
||||||
)),
|
)),
|
||||||
@ -512,7 +572,9 @@ void main() {
|
|||||||
// Regression test for https://github.com/flutter/flutter/issues/13782
|
// Regression test for https://github.com/flutter/flutter/issues/13782
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -521,6 +583,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(tester.hasRunningAnimations, isTrue);
|
expect(tester.hasRunningAnimations, isTrue);
|
||||||
|
|
||||||
@ -551,7 +614,9 @@ void main() {
|
|||||||
double? progressValue;
|
double? progressValue;
|
||||||
late StateSetter setState;
|
late StateSetter setState;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: StatefulBuilder(
|
child: StatefulBuilder(
|
||||||
@ -562,6 +627,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(tester.hasRunningAnimations, isTrue);
|
expect(tester.hasRunningAnimations, isTrue);
|
||||||
|
|
||||||
@ -576,7 +642,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator with height 12.0', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator with height 12.0', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -586,6 +654,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
find.byType(LinearProgressIndicator),
|
find.byType(LinearProgressIndicator),
|
||||||
@ -598,7 +667,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator with a height less than the minimum', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator with a height less than the minimum', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -608,6 +679,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
find.byType(LinearProgressIndicator),
|
find.byType(LinearProgressIndicator),
|
||||||
@ -620,7 +692,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('LinearProgressIndicator with default height', (WidgetTester tester) async {
|
testWidgets('LinearProgressIndicator with default height', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -630,6 +704,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
find.byType(LinearProgressIndicator),
|
find.byType(LinearProgressIndicator),
|
||||||
@ -646,7 +721,9 @@ void main() {
|
|||||||
const String label = 'Label';
|
const String label = 'Label';
|
||||||
const String value = '25%';
|
const String value = '25%';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
@ -655,6 +732,7 @@ void main() {
|
|||||||
semanticsValue: value,
|
semanticsValue: value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
||||||
@ -671,7 +749,9 @@ void main() {
|
|||||||
final GlobalKey key = GlobalKey();
|
final GlobalKey key = GlobalKey();
|
||||||
const String label = 'Label';
|
const String label = 'Label';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
@ -679,6 +759,7 @@ void main() {
|
|||||||
semanticsLabel: label,
|
semanticsLabel: label,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
||||||
@ -694,13 +775,16 @@ void main() {
|
|||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
final GlobalKey key = GlobalKey();
|
final GlobalKey key = GlobalKey();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
value: 0.25,
|
value: 0.25,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics());
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics());
|
||||||
@ -713,7 +797,9 @@ void main() {
|
|||||||
final GlobalKey key = GlobalKey();
|
final GlobalKey key = GlobalKey();
|
||||||
const String label = 'Progress';
|
const String label = 'Progress';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
@ -721,6 +807,7 @@ void main() {
|
|||||||
semanticsLabel: label,
|
semanticsLabel: label,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
||||||
@ -737,7 +824,9 @@ void main() {
|
|||||||
const String label = 'Label';
|
const String label = 'Label';
|
||||||
const String value = '25%';
|
const String value = '25%';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
@ -746,6 +835,7 @@ void main() {
|
|||||||
semanticsValue: value,
|
semanticsValue: value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
||||||
@ -763,7 +853,9 @@ void main() {
|
|||||||
const String label = 'Label';
|
const String label = 'Label';
|
||||||
const String value = '25%';
|
const String value = '25%';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
|
data: theme,
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: RefreshProgressIndicator(
|
child: RefreshProgressIndicator(
|
||||||
key: key,
|
key: key,
|
||||||
@ -771,6 +863,7 @@ void main() {
|
|||||||
semanticsValue: value,
|
semanticsValue: value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
|
||||||
@ -805,8 +898,9 @@ void main() {
|
|||||||
'Adaptive CircularProgressIndicator displays CupertinoActivityIndicator in iOS',
|
'Adaptive CircularProgressIndicator displays CupertinoActivityIndicator in iOS',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
theme: ThemeData(),
|
||||||
|
home: const Scaffold(
|
||||||
body: Material(
|
body: Material(
|
||||||
child: CircularProgressIndicator.adaptive(),
|
child: CircularProgressIndicator.adaptive(),
|
||||||
),
|
),
|
||||||
@ -826,8 +920,9 @@ void main() {
|
|||||||
'Adaptive CircularProgressIndicator can use backgroundColor to change tick color for iOS',
|
'Adaptive CircularProgressIndicator can use backgroundColor to change tick color for iOS',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
theme: ThemeData(),
|
||||||
|
home: const Scaffold(
|
||||||
body: Material(
|
body: Material(
|
||||||
child: CircularProgressIndicator.adaptive(
|
child: CircularProgressIndicator.adaptive(
|
||||||
backgroundColor: Color(0xFF5D3FD3),
|
backgroundColor: Color(0xFF5D3FD3),
|
||||||
@ -854,8 +949,9 @@ void main() {
|
|||||||
'Adaptive CircularProgressIndicator does not display CupertinoActivityIndicator in non-iOS',
|
'Adaptive CircularProgressIndicator does not display CupertinoActivityIndicator in non-iOS',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
theme: theme,
|
||||||
|
home: const Scaffold(
|
||||||
body: Material(
|
body: Material(
|
||||||
child: CircularProgressIndicator.adaptive(),
|
child: CircularProgressIndicator.adaptive(),
|
||||||
),
|
),
|
||||||
@ -893,7 +989,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
home: progressTheme,
|
home: Theme(data: theme, child: progressTheme),
|
||||||
));
|
));
|
||||||
final Widget wrappedTheme = progressTheme.wrap(builderContext, Container());
|
final Widget wrappedTheme = progressTheme.wrap(builderContext, Container());
|
||||||
|
|
||||||
@ -903,6 +999,21 @@ void main() {
|
|||||||
expect(wrappedTheme, isInstanceOf<ProgressIndicatorTheme>());
|
expect(wrappedTheme, isInstanceOf<ProgressIndicatorTheme>());
|
||||||
expect((wrappedTheme as ProgressIndicatorTheme).data, themeData);
|
expect((wrappedTheme as ProgressIndicatorTheme).data, themeData);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('default size of CircularProgressIndicator is 48x48 - M3', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: theme.copyWith(useMaterial3: true),
|
||||||
|
home: const Scaffold(
|
||||||
|
body: Material(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(tester.getSize(find.byType(CircularProgressIndicator)), const Size(48, 48));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _RefreshProgressIndicatorGolden extends StatefulWidget {
|
class _RefreshProgressIndicatorGolden extends StatefulWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user