Commit b670ce4b authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by Adam Barth

prefer const constructor (#7118)

parent 7667a3f8
......@@ -265,10 +265,10 @@ class AboutDialog extends StatelessWidget {
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
List<Widget> body = <Widget>[];
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(
child: new Padding(
padding: new EdgeInsets.symmetric(horizontal: 24.0),
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: new BlockBody(
children: <Widget>[
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) {
setState(() {
_licenses.add(new Padding(
padding: new EdgeInsets.symmetric(vertical: 18.0),
padding: const EdgeInsets.symmetric(vertical: 18.0),
child: new Text(
'🍀‬', // That's U+1F340. Could also use U+2766 (❦) if U+1F340 doesn't work everywhere.
textAlign: TextAlign.center
)
));
_licenses.add(new Container(
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0))
decoration: const BoxDecoration(
border: const Border(bottom: const BorderSide(width: 0.0))
),
child: new Text(
license.packages.join(', '),
......@@ -400,7 +400,7 @@ class _LicensePageState extends State<LicensePage> {
for (LicenseParagraph paragraph in license.paragraphs) {
if (paragraph.indent == LicenseParagraph.centeredIndent) {
_licenses.add(new Padding(
padding: new EdgeInsets.only(top: 16.0),
padding: const EdgeInsets.only(top: 16.0),
child: new Text(
paragraph.text,
style: new TextStyle(fontWeight: FontWeight.bold),
......@@ -438,7 +438,7 @@ class _LicensePageState extends State<LicensePage> {
contents.addAll(_licenses);
if (!_loaded) {
contents.add(new Padding(
padding: new EdgeInsets.symmetric(vertical: 24.0),
padding: const EdgeInsets.symmetric(vertical: 24.0),
child: new Center(
child: new CircularProgressIndicator()
)
......@@ -452,7 +452,7 @@ class _LicensePageState extends State<LicensePage> {
style: Theme.of(context).textTheme.caption,
child: new Scrollbar(
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(
children: contents
)
......
......@@ -397,7 +397,7 @@ class DataTable extends StatelessWidget {
down: sorted ? ascending : null,
duration: _kSortArrowAnimationDuration
);
final Widget arrowPadding = new SizedBox(width: _kSortArrowPadding);
final Widget arrowPadding = const SizedBox(width: _kSortArrowPadding);
label = new Row(
children: numeric ? <Widget>[ arrow, arrowPadding, label ]
: <Widget>[ label, arrowPadding, arrow ]
......
......@@ -52,9 +52,9 @@ class Dialog extends StatelessWidget {
Widget build(BuildContext context) {
return new Center(
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(
constraints: new BoxConstraints(minWidth: 280.0),
constraints: const BoxConstraints(minWidth: 280.0),
child: new Material(
elevation: 24,
color: _getColor(context),
......
......@@ -154,8 +154,8 @@ class ExpansionPanelList extends StatelessWidget {
new AnimatedCrossFade(
firstChild: new Container(height: 0.0),
secondChild: children[i].body,
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
sizeCurve: Curves.fastOutSlowIn,
crossFadeState: _isChildExpanded(i) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: animationDuration,
......
......@@ -294,7 +294,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
config.actions.map/*<Widget>*/((Widget widget) {
return new Padding(
// 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
);
}).toList()
......@@ -363,7 +363,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
: themeData.textTheme.title.copyWith(fontWeight: FontWeight.w400),
child: new IconTheme.merge(
context: context,
data: new IconThemeData(
data: const IconThemeData(
opacity: 0.54
),
child: new ButtonTheme.bar(
......@@ -399,7 +399,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
style: footerTextStyle,
child: new IconTheme.merge(
context: context,
data: new IconThemeData(
data: const IconThemeData(
opacity: 0.54
),
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 height = new CurveTween(curve: new Interval(0.0, unit * route.items.length));
Widget child = new ConstrainedBox(
constraints: new BoxConstraints(
constraints: const BoxConstraints(
minWidth: _kMenuMinWidth,
maxWidth: _kMenuMaxWidth
),
......@@ -388,7 +388,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
return new CurvedAnimation(
parent: super.createAnimation(),
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) {
return new Container(
constraints: new BoxConstraints.tightFor(
constraints: const BoxConstraints.tightFor(
width: double.INFINITY,
height: _kLinearProgressIndicatorHeight
),
......@@ -296,20 +296,20 @@ class CircularProgressIndicator extends ProgressIndicator {
// Tweens used by circular progress indicator
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(
curve: new SawTooth(5)
curve: const SawTooth(5)
));
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(
curve: new SawTooth(5)
curve: const SawTooth(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 {
AnimationController _controller;
......@@ -331,7 +331,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) {
return new Container(
constraints: new BoxConstraints(
constraints: const BoxConstraints(
minWidth: _kMinCircularProgressIndicatorSize,
minHeight: _kMinCircularProgressIndicatorSize,
),
......
......@@ -357,7 +357,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
)
.animate(new CurvedAnimation(
parent: _sizeController,
curve: new Interval(0.0, 1.0 / _kDragSizeFactorLimit)
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
));
return new Listener(
......
......@@ -310,8 +310,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
return new AnimatedCrossFade(
firstChild: _buildCircle(index, true),
secondChild: _buildTriangle(index, true),
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
sizeCurve: Curves.fastOutSlowIn,
crossFadeState: config.steps[index].state == StepState.error ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: kThemeAnimationDuration,
......@@ -503,8 +503,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
]
)
),
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
sizeCurve: Curves.fastOutSlowIn,
crossFadeState: _isCurrent(index) ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: kThemeAnimationDuration,
......
......@@ -402,7 +402,7 @@ class _Tab extends StatelessWidget {
Container centeredLabel = new Container(
child: new Center(child: labelContent, widthFactor: 1.0, heightFactor: 1.0),
constraints: new BoxConstraints(minWidth: _kMinTabWidth),
constraints: const BoxConstraints(minWidth: _kMinTabWidth),
padding: _kTabLabelPadding
);
......@@ -512,7 +512,7 @@ class TabBarSelection<T> extends StatefulWidget {
/// TabBarSelectionState<Foo> tabState = TabBarSelection.of/*<Foo>*/(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
......@@ -1302,7 +1302,7 @@ class TabPageSelector<T> extends StatelessWidget {
return new Container(
width: 12.0,
height: 12.0,
margin: new EdgeInsets.all(4.0),
margin: const EdgeInsets.all(4.0),
decoration: new BoxDecoration(
backgroundColor: background,
border: new Border.all(color: selectedColor.end),
......
......@@ -258,7 +258,7 @@ class _FlutterLogoPainter extends BoxPainter {
)
);
_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);
}
......
......@@ -52,7 +52,7 @@ class RelativeRect {
}
/// 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.
final double left;
......
......@@ -35,6 +35,6 @@ class PlaceholderState extends State<Placeholder> {
Widget build(BuildContext context) {
if (_child != null)
return child;
return new SizedBox(width: 0.0, height: 0.0);
return const SizedBox(width: 0.0, height: 0.0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment