From f4dee5c62e9e2f33418417591fb602cf06084517 Mon Sep 17 00:00:00 2001 From: Darren Austin Date: Wed, 28 Apr 2021 12:06:37 -0700 Subject: [PATCH] Fixed ProgressIndicatorTheme.wrap() to just return a new ProgressIndicatorTheme. (#81359) --- .../material/progress_indicator_theme.dart | 3 +- .../material/progress_indicator_test.dart | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/material/progress_indicator_theme.dart b/packages/flutter/lib/src/material/progress_indicator_theme.dart index b185f6fd23..0023be9cfc 100644 --- a/packages/flutter/lib/src/material/progress_indicator_theme.dart +++ b/packages/flutter/lib/src/material/progress_indicator_theme.dart @@ -177,8 +177,7 @@ class ProgressIndicatorTheme extends InheritedTheme { @override Widget wrap(BuildContext context, Widget child) { - final ProgressIndicatorTheme? ancestorTheme = context.findAncestorWidgetOfExactType(); - return identical(this, ancestorTheme) ? child : ProgressIndicatorTheme(data: data, child: child); + return ProgressIndicatorTheme(data: data, child: child); } @override diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index 095ae6a55e..c8579886d5 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -826,4 +826,35 @@ void main() { 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()); + expect((wrappedTheme as ProgressIndicatorTheme).data, themeData); + }); }