prefer const constructors (#8316)
This commit is contained in:
committed by
Adam Barth
parent
663862557b
commit
e9a775bf38
@@ -42,7 +42,7 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
canvas.rotate(math.PI/4.0);
|
||||
|
||||
ui.Gradient yellowBlue = new ui.Gradient.linear(
|
||||
<ui.Point>[new ui.Point(-radius, -radius), new ui.Point(0.0, 0.0)],
|
||||
<ui.Point>[new ui.Point(-radius, -radius), const ui.Point(0.0, 0.0)],
|
||||
<ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)]
|
||||
);
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||
@@ -61,7 +61,7 @@ ui.Picture paint(ui.Rect paintBounds) {
|
||||
canvas.restore();
|
||||
|
||||
paint.color = const ui.Color.fromARGB(128, 255, 0, 0);
|
||||
canvas.drawCircle(new ui.Point(150.0, 300.0), radius, paint);
|
||||
canvas.drawCircle(const ui.Point(150.0, 300.0), radius, paint);
|
||||
|
||||
// When we're done issuing painting commands, we end the recording an receive
|
||||
// a Picture, which is an immutable record of the commands we've issued. You
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ class RenderDots extends RenderConstrainedBox {
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
final Canvas canvas = context.canvas;
|
||||
canvas.drawRect(offset & size, new Paint()..color = new Color(0xFF0000FF));
|
||||
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
|
||||
|
||||
Paint paint = new Paint()..color = new Color(0xFF00FF00);
|
||||
Paint paint = new Paint()..color = const Color(0xFF00FF00);
|
||||
for (Point point in _dots.values)
|
||||
canvas.drawCircle(point, 50.0, paint);
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class _GestureDemoState extends State<GestureDemo> {
|
||||
left: 0.0,
|
||||
child: new Card(
|
||||
child: new Container(
|
||||
padding: new EdgeInsets.all(4.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
|
||||
@@ -93,7 +93,7 @@ class SectorAppState extends State<SectorApp> {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
padding: new EdgeInsets.symmetric(horizontal: 8.0, vertical: 25.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 25.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new RaisedButton(
|
||||
@@ -102,8 +102,8 @@ class SectorAppState extends State<SectorApp> {
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
padding: new EdgeInsets.all(4.0),
|
||||
margin: new EdgeInsets.only(right: 10.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
margin: const EdgeInsets.only(right: 10.0),
|
||||
child: new WidgetToRenderBoxAdapter(renderBox: sectorAddIcon)
|
||||
),
|
||||
new Text('ADD SECTOR'),
|
||||
@@ -117,8 +117,8 @@ class SectorAppState extends State<SectorApp> {
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
padding: new EdgeInsets.all(4.0),
|
||||
margin: new EdgeInsets.only(right: 10.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
margin: const EdgeInsets.only(right: 10.0),
|
||||
child: new WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon)
|
||||
),
|
||||
new Text('REMOVE SECTOR'),
|
||||
@@ -132,11 +132,11 @@ class SectorAppState extends State<SectorApp> {
|
||||
),
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
margin: new EdgeInsets.all(8.0),
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all()
|
||||
),
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new WidgetToRenderBoxAdapter(
|
||||
renderBox: sectors,
|
||||
onBuild: doUpdates
|
||||
|
||||
@@ -44,8 +44,8 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
|
||||
new Rectangle(const Color(0xFF00FFFF)),
|
||||
new Material(
|
||||
child: new Container(
|
||||
padding: new EdgeInsets.all(10.0),
|
||||
margin: new EdgeInsets.all(10.0),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
margin: const EdgeInsets.all(10.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new RaisedButton(
|
||||
@@ -99,7 +99,7 @@ void main() {
|
||||
addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1);
|
||||
|
||||
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: FractionalOffset.center);
|
||||
RenderPadding root = new RenderPadding(padding: new EdgeInsets.all(80.0), child: transformBox);
|
||||
RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox);
|
||||
|
||||
binding.renderView.child = root;
|
||||
binding.addPersistentFrameCallback(rotate);
|
||||
|
||||
@@ -46,7 +46,7 @@ Widget toStyledText(String name, String text) {
|
||||
style: _kUnderline,
|
||||
text: name
|
||||
),
|
||||
new TextSpan(text: ':')
|
||||
const TextSpan(text: ':')
|
||||
]
|
||||
),
|
||||
new TextSpan(text: text)
|
||||
@@ -108,7 +108,7 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
|
||||
return new GestureDetector(
|
||||
onTap: _handleTap,
|
||||
child: new Container(
|
||||
padding: new EdgeInsets.symmetric(horizontal: 8.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: new Column(
|
||||
children: children,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
Reference in New Issue
Block a user