change ThemeData.primaryColor to PrimarySwatch instead of PrimarySwatch[500] (#15265)
* change ThemeData.primaryColor to PrimarySwatch instead of PrimarySwatch[500]
* fix mismatched color in stock test case
diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart
index 6d2018c..9a592fe 100644
--- a/examples/stocks/test/icon_color_test.dart
+++ b/examples/stocks/test/icon_color_test.dart
@@ -73,7 +73,7 @@
expect(find.text('Account Balance'), findsOneWidget);
// check the colour of the icon - light mode
- checkIconColor(tester, 'Stock List', Colors.purple.shade500); // theme primary color
+ checkIconColor(tester, 'Stock List', Colors.purple); // theme primary color
checkIconColor(tester, 'Account Balance', Colors.black26); // disabled
checkIconColor(tester, 'About', Colors.black45); // enabled
diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart
index 0fe7b6d..443c0ef 100644
--- a/packages/flutter/lib/src/material/theme_data.dart
+++ b/packages/flutter/lib/src/material/theme_data.dart
@@ -118,7 +118,7 @@
brightness ??= Brightness.light;
final bool isDark = brightness == Brightness.dark;
primarySwatch ??= Colors.blue;
- primaryColor ??= isDark ? Colors.grey[900] : primarySwatch[500];
+ primaryColor ??= isDark ? Colors.grey[900] : primarySwatch;
primaryColorBrightness ??= estimateBrightnessForColor(primaryColor);
primaryColorLight ??= isDark ? Colors.grey[500] : primarySwatch[100];
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700];
diff --git a/packages/flutter/test/material/app_builder_test.dart b/packages/flutter/test/material/app_builder_test.dart
index e4cb5e3..b03a298 100644
--- a/packages/flutter/test/material/app_builder_test.dart
+++ b/packages/flutter/test/material/app_builder_test.dart
@@ -15,7 +15,7 @@
home: const Placeholder(),
builder: (BuildContext context, Widget child) {
log.add('build');
- expect(Theme.of(context).primaryColor, Colors.green.shade500);
+ expect(Theme.of(context).primaryColor, Colors.green);
expect(Directionality.of(context), TextDirection.ltr);
expect(child, const isInstanceOf<Navigator>());
return const Placeholder();
@@ -47,7 +47,7 @@
home: new Builder(
builder: (BuildContext context) {
log.add('build');
- expect(Theme.of(context).primaryColor, Colors.yellow.shade500);
+ expect(Theme.of(context).primaryColor, Colors.yellow);
expect(Directionality.of(context), TextDirection.rtl);
return const Placeholder();
},
diff --git a/packages/flutter/test/widgets/list_view_viewporting_test.dart b/packages/flutter/test/widgets/list_view_viewporting_test.dart
index 99498f1..518695e 100644
--- a/packages/flutter/test/widgets/list_view_viewporting_test.dart
+++ b/packages/flutter/test/widgets/list_view_viewporting_test.dart
@@ -236,7 +236,7 @@
DecoratedBox widget = tester.firstWidget(find.byType(DecoratedBox));
BoxDecoration decoration = widget.decoration;
- expect(decoration.color, equals(Colors.blue[500]));
+ expect(decoration.color, equals(Colors.blue));
setState(() {
themeData = new ThemeData(primarySwatch: Colors.green);
@@ -246,7 +246,7 @@
widget = tester.firstWidget(find.byType(DecoratedBox));
decoration = widget.decoration;
- expect(decoration.color, equals(Colors.green[500]));
+ expect(decoration.color, equals(Colors.green));
});
testWidgets('ListView padding', (WidgetTester tester) async {