Fixed ProgressIndicatorTheme.wrap() to just return a new ProgressIndicatorTheme. (#81359)
This commit is contained in:
parent
f6726b425d
commit
f4dee5c62e
@ -177,8 +177,7 @@ class ProgressIndicatorTheme extends InheritedTheme {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget wrap(BuildContext context, Widget child) {
|
Widget wrap(BuildContext context, Widget child) {
|
||||||
final ProgressIndicatorTheme? ancestorTheme = context.findAncestorWidgetOfExactType<ProgressIndicatorTheme>();
|
return ProgressIndicatorTheme(data: data, child: child);
|
||||||
return identical(this, ancestorTheme) ? child : ProgressIndicatorTheme(data: data, child: child);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -826,4 +826,35 @@ void main() {
|
|||||||
TargetPlatform.linux,
|
TargetPlatform.linux,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets('ProgressIndicatorTheme.wrap() always creates a new ProgressIndicatorTheme', (WidgetTester tester) async {
|
||||||
|
|
||||||
|
late BuildContext builderContext;
|
||||||
|
|
||||||
|
const ProgressIndicatorThemeData themeData = ProgressIndicatorThemeData(
|
||||||
|
color: Color(0xFFFF0000),
|
||||||
|
linearTrackColor: Color(0xFF00FF00),
|
||||||
|
);
|
||||||
|
|
||||||
|
final ProgressIndicatorTheme progressTheme = ProgressIndicatorTheme(
|
||||||
|
data: themeData,
|
||||||
|
child: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
builderContext = context;
|
||||||
|
return const LinearProgressIndicator(value: 0.5);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: progressTheme,
|
||||||
|
));
|
||||||
|
final Widget wrappedTheme = progressTheme.wrap(builderContext, Container());
|
||||||
|
|
||||||
|
// Make sure the returned widget is a new ProgressIndicatorTheme instance
|
||||||
|
// with the same theme data as the original.
|
||||||
|
expect(wrappedTheme, isNot(equals(progressTheme)));
|
||||||
|
expect(wrappedTheme, isInstanceOf<ProgressIndicatorTheme>());
|
||||||
|
expect((wrappedTheme as ProgressIndicatorTheme).data, themeData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user