prefer const constructor (#7118)
This commit is contained in:
parent
7667a3f8eb
commit
b670ce4bcc
@ -265,10 +265,10 @@ class AboutDialog extends StatelessWidget {
|
|||||||
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
||||||
List<Widget> body = <Widget>[];
|
List<Widget> body = <Widget>[];
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
body.add(new IconTheme(data: new IconThemeData(size: 48.0), child: icon));
|
body.add(new IconTheme(data: const IconThemeData(size: 48.0), child: icon));
|
||||||
body.add(new Expanded(
|
body.add(new Expanded(
|
||||||
child: new Padding(
|
child: new Padding(
|
||||||
padding: new EdgeInsets.symmetric(horizontal: 24.0),
|
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||||
child: new BlockBody(
|
child: new BlockBody(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(name, style: Theme.of(context).textTheme.headline),
|
new Text(name, style: Theme.of(context).textTheme.headline),
|
||||||
@ -381,15 +381,15 @@ class _LicensePageState extends State<LicensePage> {
|
|||||||
await for (LicenseEntry license in LicenseRegistry.licenses) {
|
await for (LicenseEntry license in LicenseRegistry.licenses) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_licenses.add(new Padding(
|
_licenses.add(new Padding(
|
||||||
padding: new EdgeInsets.symmetric(vertical: 18.0),
|
padding: const EdgeInsets.symmetric(vertical: 18.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
'🍀', // That's U+1F340. Could also use U+2766 (❦) if U+1F340 doesn't work everywhere.
|
'🍀', // That's U+1F340. Could also use U+2766 (❦) if U+1F340 doesn't work everywhere.
|
||||||
textAlign: TextAlign.center
|
textAlign: TextAlign.center
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
_licenses.add(new Container(
|
_licenses.add(new Container(
|
||||||
decoration: new BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: new Border(bottom: new BorderSide(width: 0.0))
|
border: const Border(bottom: const BorderSide(width: 0.0))
|
||||||
),
|
),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
license.packages.join(', '),
|
license.packages.join(', '),
|
||||||
@ -400,7 +400,7 @@ class _LicensePageState extends State<LicensePage> {
|
|||||||
for (LicenseParagraph paragraph in license.paragraphs) {
|
for (LicenseParagraph paragraph in license.paragraphs) {
|
||||||
if (paragraph.indent == LicenseParagraph.centeredIndent) {
|
if (paragraph.indent == LicenseParagraph.centeredIndent) {
|
||||||
_licenses.add(new Padding(
|
_licenses.add(new Padding(
|
||||||
padding: new EdgeInsets.only(top: 16.0),
|
padding: const EdgeInsets.only(top: 16.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
paragraph.text,
|
paragraph.text,
|
||||||
style: new TextStyle(fontWeight: FontWeight.bold),
|
style: new TextStyle(fontWeight: FontWeight.bold),
|
||||||
@ -438,7 +438,7 @@ class _LicensePageState extends State<LicensePage> {
|
|||||||
contents.addAll(_licenses);
|
contents.addAll(_licenses);
|
||||||
if (!_loaded) {
|
if (!_loaded) {
|
||||||
contents.add(new Padding(
|
contents.add(new Padding(
|
||||||
padding: new EdgeInsets.symmetric(vertical: 24.0),
|
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||||
child: new Center(
|
child: new Center(
|
||||||
child: new CircularProgressIndicator()
|
child: new CircularProgressIndicator()
|
||||||
)
|
)
|
||||||
@ -452,7 +452,7 @@ class _LicensePageState extends State<LicensePage> {
|
|||||||
style: Theme.of(context).textTheme.caption,
|
style: Theme.of(context).textTheme.caption,
|
||||||
child: new Scrollbar(
|
child: new Scrollbar(
|
||||||
child: new LazyBlock(
|
child: new LazyBlock(
|
||||||
padding: new EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
|
||||||
delegate: new LazyBlockChildren(
|
delegate: new LazyBlockChildren(
|
||||||
children: contents
|
children: contents
|
||||||
)
|
)
|
||||||
|
@ -397,7 +397,7 @@ class DataTable extends StatelessWidget {
|
|||||||
down: sorted ? ascending : null,
|
down: sorted ? ascending : null,
|
||||||
duration: _kSortArrowAnimationDuration
|
duration: _kSortArrowAnimationDuration
|
||||||
);
|
);
|
||||||
final Widget arrowPadding = new SizedBox(width: _kSortArrowPadding);
|
final Widget arrowPadding = const SizedBox(width: _kSortArrowPadding);
|
||||||
label = new Row(
|
label = new Row(
|
||||||
children: numeric ? <Widget>[ arrow, arrowPadding, label ]
|
children: numeric ? <Widget>[ arrow, arrowPadding, label ]
|
||||||
: <Widget>[ label, arrowPadding, arrow ]
|
: <Widget>[ label, arrowPadding, arrow ]
|
||||||
|
@ -52,9 +52,9 @@ class Dialog extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Center(
|
return new Center(
|
||||||
child: new Container(
|
child: new Container(
|
||||||
margin: new EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),
|
margin: const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),
|
||||||
child: new ConstrainedBox(
|
child: new ConstrainedBox(
|
||||||
constraints: new BoxConstraints(minWidth: 280.0),
|
constraints: const BoxConstraints(minWidth: 280.0),
|
||||||
child: new Material(
|
child: new Material(
|
||||||
elevation: 24,
|
elevation: 24,
|
||||||
color: _getColor(context),
|
color: _getColor(context),
|
||||||
|
@ -154,8 +154,8 @@ class ExpansionPanelList extends StatelessWidget {
|
|||||||
new AnimatedCrossFade(
|
new AnimatedCrossFade(
|
||||||
firstChild: new Container(height: 0.0),
|
firstChild: new Container(height: 0.0),
|
||||||
secondChild: children[i].body,
|
secondChild: children[i].body,
|
||||||
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
||||||
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
||||||
sizeCurve: Curves.fastOutSlowIn,
|
sizeCurve: Curves.fastOutSlowIn,
|
||||||
crossFadeState: _isChildExpanded(i) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
crossFadeState: _isChildExpanded(i) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||||
duration: animationDuration,
|
duration: animationDuration,
|
||||||
|
@ -294,7 +294,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
|
|||||||
config.actions.map/*<Widget>*/((Widget widget) {
|
config.actions.map/*<Widget>*/((Widget widget) {
|
||||||
return new Padding(
|
return new Padding(
|
||||||
// 8.0 is the default padding of an icon button
|
// 8.0 is the default padding of an icon button
|
||||||
padding: new EdgeInsets.only(left: 24.0 - 8.0 * 2.0),
|
padding: const EdgeInsets.only(left: 24.0 - 8.0 * 2.0),
|
||||||
child: widget
|
child: widget
|
||||||
);
|
);
|
||||||
}).toList()
|
}).toList()
|
||||||
@ -363,7 +363,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
|
|||||||
: themeData.textTheme.title.copyWith(fontWeight: FontWeight.w400),
|
: themeData.textTheme.title.copyWith(fontWeight: FontWeight.w400),
|
||||||
child: new IconTheme.merge(
|
child: new IconTheme.merge(
|
||||||
context: context,
|
context: context,
|
||||||
data: new IconThemeData(
|
data: const IconThemeData(
|
||||||
opacity: 0.54
|
opacity: 0.54
|
||||||
),
|
),
|
||||||
child: new ButtonTheme.bar(
|
child: new ButtonTheme.bar(
|
||||||
@ -399,7 +399,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
|
|||||||
style: footerTextStyle,
|
style: footerTextStyle,
|
||||||
child: new IconTheme.merge(
|
child: new IconTheme.merge(
|
||||||
context: context,
|
context: context,
|
||||||
data: new IconThemeData(
|
data: const IconThemeData(
|
||||||
opacity: 0.54
|
opacity: 0.54
|
||||||
),
|
),
|
||||||
child: new Container(
|
child: new Container(
|
||||||
|
@ -285,12 +285,12 @@ class _PopupMenu<T> extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
final CurveTween opacity = new CurveTween(curve: new Interval(0.0, 1.0 / 3.0));
|
final CurveTween opacity = new CurveTween(curve: const Interval(0.0, 1.0 / 3.0));
|
||||||
final CurveTween width = new CurveTween(curve: new Interval(0.0, unit));
|
final CurveTween width = new CurveTween(curve: new Interval(0.0, unit));
|
||||||
final CurveTween height = new CurveTween(curve: new Interval(0.0, unit * route.items.length));
|
final CurveTween height = new CurveTween(curve: new Interval(0.0, unit * route.items.length));
|
||||||
|
|
||||||
Widget child = new ConstrainedBox(
|
Widget child = new ConstrainedBox(
|
||||||
constraints: new BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minWidth: _kMenuMinWidth,
|
minWidth: _kMenuMinWidth,
|
||||||
maxWidth: _kMenuMaxWidth
|
maxWidth: _kMenuMaxWidth
|
||||||
),
|
),
|
||||||
@ -388,7 +388,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
|
|||||||
return new CurvedAnimation(
|
return new CurvedAnimation(
|
||||||
parent: super.createAnimation(),
|
parent: super.createAnimation(),
|
||||||
curve: Curves.linear,
|
curve: Curves.linear,
|
||||||
reverseCurve: new Interval(0.0, _kMenuCloseIntervalEnd)
|
reverseCurve: const Interval(0.0, _kMenuCloseIntervalEnd)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
|
|||||||
|
|
||||||
Widget _buildIndicator(BuildContext context, double animationValue) {
|
Widget _buildIndicator(BuildContext context, double animationValue) {
|
||||||
return new Container(
|
return new Container(
|
||||||
constraints: new BoxConstraints.tightFor(
|
constraints: const BoxConstraints.tightFor(
|
||||||
width: double.INFINITY,
|
width: double.INFINITY,
|
||||||
height: _kLinearProgressIndicatorHeight
|
height: _kLinearProgressIndicatorHeight
|
||||||
),
|
),
|
||||||
@ -296,20 +296,20 @@ class CircularProgressIndicator extends ProgressIndicator {
|
|||||||
|
|
||||||
// Tweens used by circular progress indicator
|
// Tweens used by circular progress indicator
|
||||||
final Animatable<double> _kStrokeHeadTween = new CurveTween(
|
final Animatable<double> _kStrokeHeadTween = new CurveTween(
|
||||||
curve: new Interval(0.0, 0.5, curve: Curves.fastOutSlowIn)
|
curve: const Interval(0.0, 0.5, curve: Curves.fastOutSlowIn)
|
||||||
).chain(new CurveTween(
|
).chain(new CurveTween(
|
||||||
curve: new SawTooth(5)
|
curve: const SawTooth(5)
|
||||||
));
|
));
|
||||||
|
|
||||||
final Animatable<double> _kStrokeTailTween = new CurveTween(
|
final Animatable<double> _kStrokeTailTween = new CurveTween(
|
||||||
curve: new Interval(0.5, 1.0, curve: Curves.fastOutSlowIn)
|
curve: const Interval(0.5, 1.0, curve: Curves.fastOutSlowIn)
|
||||||
).chain(new CurveTween(
|
).chain(new CurveTween(
|
||||||
curve: new SawTooth(5)
|
curve: const SawTooth(5)
|
||||||
));
|
));
|
||||||
|
|
||||||
final Animatable<int> _kStepTween = new StepTween(begin: 0, end: 5);
|
final Animatable<int> _kStepTween = new StepTween(begin: 0, end: 5);
|
||||||
|
|
||||||
final Animatable<double> _kRotationTween = new CurveTween(curve: new SawTooth(5));
|
final Animatable<double> _kRotationTween = new CurveTween(curve: const SawTooth(5));
|
||||||
|
|
||||||
class _CircularProgressIndicatorState extends State<CircularProgressIndicator> with SingleTickerProviderStateMixin {
|
class _CircularProgressIndicatorState extends State<CircularProgressIndicator> with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
@ -331,7 +331,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
|
|||||||
|
|
||||||
Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) {
|
Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) {
|
||||||
return new Container(
|
return new Container(
|
||||||
constraints: new BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minWidth: _kMinCircularProgressIndicatorSize,
|
minWidth: _kMinCircularProgressIndicatorSize,
|
||||||
minHeight: _kMinCircularProgressIndicatorSize,
|
minHeight: _kMinCircularProgressIndicatorSize,
|
||||||
),
|
),
|
||||||
|
@ -357,7 +357,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
|||||||
)
|
)
|
||||||
.animate(new CurvedAnimation(
|
.animate(new CurvedAnimation(
|
||||||
parent: _sizeController,
|
parent: _sizeController,
|
||||||
curve: new Interval(0.0, 1.0 / _kDragSizeFactorLimit)
|
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
|
||||||
));
|
));
|
||||||
|
|
||||||
return new Listener(
|
return new Listener(
|
||||||
|
@ -310,8 +310,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
|
|||||||
return new AnimatedCrossFade(
|
return new AnimatedCrossFade(
|
||||||
firstChild: _buildCircle(index, true),
|
firstChild: _buildCircle(index, true),
|
||||||
secondChild: _buildTriangle(index, true),
|
secondChild: _buildTriangle(index, true),
|
||||||
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
||||||
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
||||||
sizeCurve: Curves.fastOutSlowIn,
|
sizeCurve: Curves.fastOutSlowIn,
|
||||||
crossFadeState: config.steps[index].state == StepState.error ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
crossFadeState: config.steps[index].state == StepState.error ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||||
duration: kThemeAnimationDuration,
|
duration: kThemeAnimationDuration,
|
||||||
@ -503,8 +503,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
|
||||||
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
|
||||||
sizeCurve: Curves.fastOutSlowIn,
|
sizeCurve: Curves.fastOutSlowIn,
|
||||||
crossFadeState: _isCurrent(index) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
crossFadeState: _isCurrent(index) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||||
duration: kThemeAnimationDuration,
|
duration: kThemeAnimationDuration,
|
||||||
|
@ -402,7 +402,7 @@ class _Tab extends StatelessWidget {
|
|||||||
|
|
||||||
Container centeredLabel = new Container(
|
Container centeredLabel = new Container(
|
||||||
child: new Center(child: labelContent, widthFactor: 1.0, heightFactor: 1.0),
|
child: new Center(child: labelContent, widthFactor: 1.0, heightFactor: 1.0),
|
||||||
constraints: new BoxConstraints(minWidth: _kMinTabWidth),
|
constraints: const BoxConstraints(minWidth: _kMinTabWidth),
|
||||||
padding: _kTabLabelPadding
|
padding: _kTabLabelPadding
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ class TabBarSelection<T> extends StatefulWidget {
|
|||||||
/// TabBarSelectionState<Foo> tabState = TabBarSelection.of/*<Foo>*/(context);
|
/// TabBarSelectionState<Foo> tabState = TabBarSelection.of/*<Foo>*/(context);
|
||||||
/// ```
|
/// ```
|
||||||
static TabBarSelectionState<dynamic/*=T*/> of/*<T>*/(BuildContext context) {
|
static TabBarSelectionState<dynamic/*=T*/> of/*<T>*/(BuildContext context) {
|
||||||
return context.ancestorStateOfType(new TypeMatcher<TabBarSelectionState<dynamic/*=T*/>>());
|
return context.ancestorStateOfType(const TypeMatcher<TabBarSelectionState<dynamic/*=T*/>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1302,7 +1302,7 @@ class TabPageSelector<T> extends StatelessWidget {
|
|||||||
return new Container(
|
return new Container(
|
||||||
width: 12.0,
|
width: 12.0,
|
||||||
height: 12.0,
|
height: 12.0,
|
||||||
margin: new EdgeInsets.all(4.0),
|
margin: const EdgeInsets.all(4.0),
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
backgroundColor: background,
|
backgroundColor: background,
|
||||||
border: new Border.all(color: selectedColor.end),
|
border: new Border.all(color: selectedColor.end),
|
||||||
|
@ -258,7 +258,7 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
_textPainter.layout();
|
_textPainter.layout();
|
||||||
final ui.TextBox textSize = _textPainter.getBoxesForSelection(new TextSelection(baseOffset: 0, extentOffset: kLabel.length)).single;
|
final ui.TextBox textSize = _textPainter.getBoxesForSelection(const TextSelection(baseOffset: 0, extentOffset: kLabel.length)).single;
|
||||||
_textBoundingRect = new Rect.fromLTRB(textSize.left, textSize.top, textSize.right, textSize.bottom);
|
_textBoundingRect = new Rect.fromLTRB(textSize.left, textSize.top, textSize.right, textSize.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class RelativeRect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A rect that covers the entire container.
|
/// A rect that covers the entire container.
|
||||||
static final RelativeRect fill = new RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0);
|
static final RelativeRect fill = const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
/// Distance from the left side of the container to the left side of this rectangle.
|
/// Distance from the left side of the container to the left side of this rectangle.
|
||||||
final double left;
|
final double left;
|
||||||
|
@ -35,6 +35,6 @@ class PlaceholderState extends State<Placeholder> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_child != null)
|
if (_child != null)
|
||||||
return child;
|
return child;
|
||||||
return new SizedBox(width: 0.0, height: 0.0);
|
return const SizedBox(width: 0.0, height: 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user