Rename DefaultTextStyle constructor to explicit (#3920)

To make it clear that this constructor requires an explicit style. Also
throw a descriptive error recommending the inherit constructor for
styles with the inherit bit set.

Fixes #3842
This commit is contained in:
Adam Barth
2016-05-16 10:35:35 -07:00
parent 707fe582a6
commit 55f9145ef4
22 changed files with 52 additions and 30 deletions

View File

@@ -84,7 +84,7 @@ class ColorSwatchTabView extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<Widget> colorItems = swatch.colors.keys.map((int index) {
return new DefaultTextStyle(
return new DefaultTextStyle.explicit(
style: index > swatch.threshold ? whiteTextStyle : blackTextStyle,
child: new ColorItem(index: index, color: swatch.colors[index])
);
@@ -93,7 +93,7 @@ class ColorSwatchTabView extends StatelessWidget {
if (swatch.accentColors != null) {
colorItems.addAll(swatch.accentColors.keys.map((int index) {
return new DefaultTextStyle(
return new DefaultTextStyle.explicit(
style: index > swatch.threshold ? whiteTextStyle : blackTextStyle,
child: new ColorItem(index: index, color: swatch.accentColors[index], prefix: 'A')
);

View File

@@ -18,7 +18,7 @@ class _ContactCategory extends StatelessWidget {
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(color: Theme.of(context).dividerColor))
),
child: new DefaultTextStyle(
child: new DefaultTextStyle.explicit(
style: Theme.of(context).textTheme.subhead,
child: new Row(
children: <Widget>[

View File

@@ -31,7 +31,7 @@ class DateTimeItem extends StatelessWidget {
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
return new DefaultTextStyle(
return new DefaultTextStyle.explicit(
style: theme.textTheme.subhead,
child: new Row(
children: <Widget>[

View File

@@ -94,7 +94,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Progress indicators')),
body: new DefaultTextStyle(
body: new DefaultTextStyle.explicit(
style: Theme.of(context).textTheme.title,
child: new GestureDetector(
onTap: _handleTap,

View File

@@ -26,8 +26,8 @@ class _BarGraphic extends StatelessWidget {
width: 200.0,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
decoration: new BoxDecoration(backgroundColor: color),
child: new DefaultTextStyle(
style: Theme.of(context).textTheme.body1.copyWith(color: Colors.white),
child: new DefaultTextStyle.explicit(
style: Typography.white.body1,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[