use color.shadeXxx instead of color[Xxx] (#8932)

* use color.shadeXxx instead of color[Xxx]

* remove calls to .shade500 on MaterialColor

* remove calls to .shade200 on MaterialAccentColor

* fix test
This commit is contained in:
Alexandre Ardhuin
2017-03-21 23:14:55 +01:00
committed by GitHub
parent fac2fac1d6
commit 578ca0a295
33 changed files with 77 additions and 77 deletions

View File

@@ -151,7 +151,7 @@ class SectionDetailView extends StatelessWidget {
}
return new DecoratedBox(
decoration: new BoxDecoration(backgroundColor: Colors.grey[200]),
decoration: new BoxDecoration(backgroundColor: Colors.grey.shade200),
child: item,
);
}

View File

@@ -98,31 +98,31 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
new NavigationIconView(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm'),
color: Colors.deepPurple[500],
color: Colors.deepPurple,
vsync: this,
),
new NavigationIconView(
icon: new CustomIcon(),
title: new Text('Box'),
color: Colors.deepOrange[500],
color: Colors.deepOrange,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.cloud),
title: new Text('Cloud'),
color: Colors.teal[500],
color: Colors.teal,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.favorite),
title: new Text('Favorites'),
color: Colors.indigo[500],
color: Colors.indigo,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.event_available),
title: new Text('Event'),
color: Colors.pink[500],
color: Colors.pink,
vsync: this,
)
];

View File

@@ -35,7 +35,7 @@ class _InputDropdown extends StatelessWidget {
children: <Widget>[
new Text(valueText, style: valueStyle),
new Icon(Icons.arrow_drop_down,
color: Theme.of(context).brightness == Brightness.light ? Colors.grey[700] : Colors.white70
color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70
),
],
),

View File

@@ -75,7 +75,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
appBar: new AppBar(title: new Text('Persistent bottom sheet')),
floatingActionButton: new FloatingActionButton(
onPressed: _showMessage,
backgroundColor: Colors.redAccent[200],
backgroundColor: Colors.redAccent,
child: new Icon(Icons.add)
),
body: new Center(

View File

@@ -17,9 +17,9 @@ class _Page {
final MaterialColor colors;
final IconData icon;
Color get labelColor => colors != null ? colors[300] : Colors.grey[300];
Color get labelColor => colors != null ? colors.shade300 : Colors.grey.shade300;
bool get fabDefined => colors != null && icon != null;
Color get fabColor => colors[400];
Color get fabColor => colors.shade400;
Icon get fabIcon => new Icon(icon);
Key get fabKey => new ValueKey<Color>(fabColor);
}

View File

@@ -25,7 +25,7 @@ final Set<Recipe> _favoriteRecipes = new Set<Recipe>();
final ThemeData _kTheme = new ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.teal,
accentColor: Colors.redAccent[200],
accentColor: Colors.redAccent,
);
class PestoHome extends StatelessWidget {

View File

@@ -127,7 +127,7 @@ class GalleryAppState extends State<GalleryApp> {
return new MaterialApp(
title: 'Flutter Gallery',
color: Colors.grey[500],
color: Colors.grey,
theme: (_useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme).copyWith(platform: _platform ?? defaultTargetPlatform),
showPerformanceOverlay: _showPerformanceOverlay,
checkerboardRasterCacheImages: _checkerboardRasterCacheImages,

View File

@@ -10,12 +10,12 @@ import 'package:flutter/rendering.dart';
// Material design colors. :p
List<Color> _kColors = <Color>[
Colors.teal[500],
Colors.amber[500],
Colors.purple[500],
Colors.lightBlue[500],
Colors.deepPurple[500],
Colors.lime[500],
Colors.teal,
Colors.amber,
Colors.purple,
Colors.lightBlue,
Colors.deepPurple,
Colors.lime,
];
/// A simple model object for a dot that reacts to pointer pressure.

View File

@@ -30,8 +30,8 @@ class _GesturePainter extends CustomPainter {
final Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint();
final double radius = size.width / 2.0 * zoom;
final Gradient gradient = new RadialGradient(
colors: forward ? <Color>[swatch[50], swatch[900]]
: <Color>[swatch[900], swatch[50]]
colors: forward ? <Color>[swatch.shade50, swatch.shade900]
: <Color>[swatch.shade900, swatch.shade50]
);
final Paint paint = new Paint()
..shader = gradient.createShader(new Rect.fromLTWH(

View File

@@ -18,7 +18,7 @@ class AdaptedListItem extends StatelessWidget {
height: 32.0,
margin: const EdgeInsets.all(8.0),
decoration: new BoxDecoration(
backgroundColor: Colors.lightBlueAccent[100]
backgroundColor: Colors.lightBlueAccent.shade100
)
),
new Text(name)
@@ -40,7 +40,7 @@ class AdaptedGridItem extends StatelessWidget {
new Expanded(
child: new Container(
decoration: new BoxDecoration(
backgroundColor: Colors.lightBlueAccent[100]
backgroundColor: Colors.lightBlueAccent.shade100
)
)
),

View File

@@ -23,8 +23,8 @@ final List<List<String>> _kNameLines = _kDialogText
.map((String line) => line.split(':'))
.toList();
final TextStyle _kDaveStyle = new TextStyle(color: Colors.indigo[400], height: 1.8);
final TextStyle _kHalStyle = new TextStyle(color: Colors.red[400], fontFamily: "monospace");
final TextStyle _kDaveStyle = new TextStyle(color: Colors.indigo.shade400, height: 1.8);
final TextStyle _kHalStyle = new TextStyle(color: Colors.red.shade400, fontFamily: "monospace");
final TextStyle _kBold = const TextStyle(fontWeight: FontWeight.bold);
final TextStyle _kUnderline = const TextStyle(
decoration: TextDecoration.underline,
@@ -127,7 +127,7 @@ void main() {
title: new Text('Hal and Dave')
),
body: new Material(
color: Colors.grey[50],
color: Colors.grey.shade50,
child: new StyledTextDemo()
)
)

View File

@@ -72,7 +72,7 @@ class StocksAppState extends State<StocksApp> {
case StockMode.pessimistic:
return new ThemeData(
brightness: Brightness.dark,
accentColor: Colors.redAccent[200]
accentColor: Colors.redAccent
);
}
assert(_configuration.stockMode != null);

View File

@@ -312,7 +312,7 @@ class StockHomeState extends State<StockHome> {
return new FloatingActionButton(
tooltip: 'Create company',
child: new Icon(Icons.add),
backgroundColor: Colors.redAccent[200],
backgroundColor: Colors.redAccent,
onPressed: _handleCreateCompany
);
}

View File

@@ -76,7 +76,7 @@ void main() {
expect(find.text('Account Balance'), findsOneWidget);
// check the colour of the icon - light mode
checkIconColor(tester, 'Stock List', Colors.purple[500]); // theme primary color
checkIconColor(tester, 'Stock List', Colors.purple.shade500); // theme primary color
checkIconColor(tester, 'Account Balance', Colors.black26); // disabled
checkIconColor(tester, 'About', Colors.black45); // enabled
@@ -87,7 +87,7 @@ void main() {
await tester.pump(const Duration(seconds: 5)); // end the transition
// check the colour of the icon - dark mode
checkIconColor(tester, 'Stock List', Colors.redAccent[200]); // theme accent color
checkIconColor(tester, 'Stock List', Colors.redAccent); // theme accent color
checkIconColor(tester, 'Account Balance', Colors.white30); // disabled
checkIconColor(tester, 'About', Colors.white); // enabled
});