prefer const constructors (#8316)

This commit is contained in:
Alexandre Ardhuin
2017-02-21 23:54:29 +01:00
committed by Adam Barth
parent 663862557b
commit e9a775bf38
43 changed files with 145 additions and 145 deletions

View File

@@ -15,25 +15,25 @@ void main() {
void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) {
TextStyle style = const TextStyle(color: const Color(0xFF000000));
RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$crossAxisAlignment'));
table.add(new RenderPadding(child: paragraph, padding: new EdgeInsets.only(top: 20.0)));
table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0)));
RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = new TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
style = const TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
decoration: const BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo'))
));
style = new TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
style = const TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo'))
));
RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = new TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
style = const TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
subrow.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo foo'))
));
subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: new Size(30.0, 40.0)));
subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0)));
row.add(subrow);
table.add(row);
final FlexParentData rowParentData = row.parentData;
@@ -49,11 +49,11 @@ void main() {
void addJustificationRow(MainAxisAlignment justify) {
const TextStyle style = const TextStyle(color: const Color(0xFF000000));
RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$justify'));
table.add(new RenderPadding(child: paragraph, padding: new EdgeInsets.only(top: 20.0)));
table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0)));
RenderFlex row = new RenderFlex(direction: Axis.horizontal);
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: new Size(80.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: new Size(64.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: new Size(160.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: const Size(64.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0)));
row.mainAxisAlignment = justify;
table.add(row);
final FlexParentData rowParentData = row.parentData;
@@ -67,8 +67,8 @@ void main() {
addJustificationRow(MainAxisAlignment.spaceAround);
RenderDecoratedBox root = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
child: new RenderPadding(child: table, padding: new EdgeInsets.symmetric(vertical: 50.0))
decoration: const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0))
);
new RenderingFlutterBinding(root: root);

View File

@@ -16,7 +16,7 @@ void main() {
alignment: FractionalOffset.center,
// We use a RenderParagraph to display the text 'Hello, world.' without
// any explicit styling.
child: new RenderParagraph(new TextSpan(text: 'Hello, world.'))
child: new RenderParagraph(const TextSpan(text: 'Hello, world.'))
)
);
}

View File

@@ -572,7 +572,7 @@ class RenderSolidColor extends RenderDecoratedSector {
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
if (event is PointerDownEvent) {
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
decoration = const BoxDecoration(backgroundColor: const Color(0xFFFF0000));
} else if (event is PointerUpEvent) {
decoration = new BoxDecoration(backgroundColor: backgroundColor);
}

View File

@@ -41,7 +41,7 @@ class RenderSolidColorBox extends RenderDecoratedBox {
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent) {
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
decoration = const BoxDecoration(backgroundColor: const Color(0xFFFF0000));
} else if (event is PointerUpEvent) {
decoration = new BoxDecoration(backgroundColor: backgroundColor);
}