From 9a8b460209013a77bca0e46b2fe53999c9f8c9b8 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 14 Mar 2018 10:39:56 -0700 Subject: [PATCH] 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 --- examples/stocks/test/icon_color_test.dart | 2 +- packages/flutter/lib/src/material/theme_data.dart | 2 +- packages/flutter/test/material/app_builder_test.dart | 4 ++-- packages/flutter/test/widgets/list_view_viewporting_test.dart | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart index 6d2018c0eb..9a592fecd9 100644 --- a/examples/stocks/test/icon_color_test.dart +++ b/examples/stocks/test/icon_color_test.dart @@ -73,7 +73,7 @@ void main() { 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 0fe7b6d9b2..443c0ef4c2 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -118,7 +118,7 @@ class ThemeData extends Diagnosticable { 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 e4cb5e3c1d..b03a298fda 100644 --- a/packages/flutter/test/material/app_builder_test.dart +++ b/packages/flutter/test/material/app_builder_test.dart @@ -15,7 +15,7 @@ void main() { 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()); return const Placeholder(); @@ -47,7 +47,7 @@ void main() { 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 99498f1573..518695e204 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 @@ void main() { 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 @@ void main() { 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 {