Unnecessary new (#20138) * enable lint unnecessary_new * fix tests * fix tests * fix tests
diff --git a/examples/layers/raw/canvas.dart b/examples/layers/raw/canvas.dart index 6173a4c..bd5d586 100644 --- a/examples/layers/raw/canvas.dart +++ b/examples/layers/raw/canvas.dart
@@ -13,17 +13,17 @@ // First we create a PictureRecorder to record the commands we're going to // feed in the canvas. The PictureRecorder will eventually produce a Picture, // which is an immutable record of those commands. - final ui.PictureRecorder recorder = new ui.PictureRecorder(); + final ui.PictureRecorder recorder = ui.PictureRecorder(); // Next, we create a canvas from the recorder. The canvas is an interface // which can receive drawing commands. The canvas interface is modeled after // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // for the canvas, which lets the implementation discard any commands that // are entirely outside this rectangle. - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); - final ui.Paint paint = new ui.Paint(); - canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF)); + final ui.Paint paint = ui.Paint(); + canvas.drawPaint(ui.Paint()..color = const ui.Color(0xFFFFFFFF)); final ui.Size size = paintBounds.size; final ui.Offset mid = size.center(ui.Offset.zero); @@ -34,22 +34,22 @@ canvas.save(); canvas.translate(-mid.dx / 2.0, logicalSize.height * 2.0); - canvas.clipRect(new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius)); + canvas.clipRect(ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius)); canvas.translate(mid.dx, mid.dy); paint.color = const ui.Color.fromARGB(128, 255, 0, 255); canvas.rotate(math.pi/4.0); - final ui.Gradient yellowBlue = new ui.Gradient.linear( - new ui.Offset(-radius, -radius), + final ui.Gradient yellowBlue = ui.Gradient.linear( + ui.Offset(-radius, -radius), const ui.Offset(0.0, 0.0), <ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)], ); - canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius), - new ui.Paint()..shader = yellowBlue); + canvas.drawRect(ui.Rect.fromLTRB(-radius, -radius, radius, radius), + ui.Paint()..shader = yellowBlue); // Scale x and y by 0.5. - final Float64List scaleMatrix = new Float64List.fromList(<double>[ + final Float64List scaleMatrix = Float64List.fromList(<double>[ 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -72,12 +72,12 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop();
diff --git a/examples/layers/raw/hello_world.dart b/examples/layers/raw/hello_world.dart index 83d3bb5..7a9294a 100644 --- a/examples/layers/raw/hello_world.dart +++ b/examples/layers/raw/hello_world.dart
@@ -11,24 +11,24 @@ final double devicePixelRatio = ui.window.devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; - final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder( - new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), + final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder( + ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), ) ..addText('Hello, world.'); final ui.Paragraph paragraph = paragraphBuilder.build() - ..layout(new ui.ParagraphConstraints(width: logicalSize.width)); + ..layout(ui.ParagraphConstraints(width: logicalSize.width)); final ui.Rect physicalBounds = ui.Offset.zero & (logicalSize * devicePixelRatio); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, physicalBounds); canvas.scale(devicePixelRatio, devicePixelRatio); - canvas.drawParagraph(paragraph, new ui.Offset( + canvas.drawParagraph(paragraph, ui.Offset( (logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0, (logicalSize.height - paragraph.height) / 2.0 )); final ui.Picture picture = recorder.endRecording(); - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() // TODO(abarth): We should be able to add a picture without pushing a // container layer first. ..pushClipRect(physicalBounds)
diff --git a/examples/layers/raw/spinning_square.dart b/examples/layers/raw/spinning_square.dart index 1bc64c6..adcbb8d 100644 --- a/examples/layers/raw/spinning_square.dart +++ b/examples/layers/raw/spinning_square.dart
@@ -20,8 +20,8 @@ // PAINT final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0); // Here we determine the rotation according to the timeStamp given to us by @@ -29,19 +29,19 @@ final double t = timeStamp.inMicroseconds / Duration.microsecondsPerMillisecond / 1800.0; canvas.rotate(math.pi * (t % 1.0)); - canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), - new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); + canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), + ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); final ui.Picture picture = recorder.endRecording(); // COMPOSITE final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop();
diff --git a/examples/layers/raw/text.dart b/examples/layers/raw/text.dart index 6320822..a54b904 100644 --- a/examples/layers/raw/text.dart +++ b/examples/layers/raw/text.dart
@@ -12,31 +12,31 @@ ui.Paragraph paragraph; ui.Picture paint(ui.Rect paintBounds) { - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); final double devicePixelRatio = ui.window.devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; canvas.translate(logicalSize.width / 2.0, logicalSize.height / 2.0); - canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), - new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); + canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), + ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); // The paint method of Paragraph draws the contents of the paragraph onto the // given canvas. - canvas.drawParagraph(paragraph, new ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0)); + canvas.drawParagraph(paragraph, ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0)); return recorder.endRecording(); } ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop(); @@ -52,18 +52,18 @@ void main() { // To create a paragraph of text, we use ParagraphBuilder. - final ui.ParagraphBuilder builder = new ui.ParagraphBuilder( + final ui.ParagraphBuilder builder = ui.ParagraphBuilder( // The text below has a primary direction of left-to-right. // The embedded text has other directions. // If this was TextDirection.rtl, the "Hello, world" text would end up on // the other side of the right-to-left text. - new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), + ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), ) // We first push a style that turns the text blue. - ..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF))) + ..pushStyle(ui.TextStyle(color: const ui.Color(0xFF0000FF))) ..addText('Hello, ') // The next run of text will be bold. - ..pushStyle(new ui.TextStyle(fontWeight: ui.FontWeight.bold)) + ..pushStyle(ui.TextStyle(fontWeight: ui.FontWeight.bold)) ..addText('world. ') // The pop() command signals the end of the bold styling. ..pop() @@ -84,7 +84,7 @@ // Next, we supply a width that the text is permitted to occupy and we ask // the paragraph to the visual position of each its glyphs as well as its // overall size, subject to its sizing constraints. - ..layout(new ui.ParagraphConstraints(width: 180.0)); + ..layout(ui.ParagraphConstraints(width: 180.0)); // Finally, we register our beginFrame callback and kick off the first frame. ui.window.onBeginFrame = beginFrame;
diff --git a/examples/layers/raw/touch_input.dart b/examples/layers/raw/touch_input.dart index 05cf21e..52932b1 100644 --- a/examples/layers/raw/touch_input.dart +++ b/examples/layers/raw/touch_input.dart
@@ -14,21 +14,21 @@ // First we create a PictureRecorder to record the commands we're going to // feed in the canvas. The PictureRecorder will eventually produce a Picture, // which is an immutable record of those commands. - final ui.PictureRecorder recorder = new ui.PictureRecorder(); + final ui.PictureRecorder recorder = ui.PictureRecorder(); // Next, we create a canvas from the recorder. The canvas is an interface // which can receive drawing commands. The canvas interface is modeled after // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // for the canvas, which lets the implementation discard any commands that // are entirely outside this rectangle. - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); // The commands draw a circle in the center of the screen. final ui.Size size = paintBounds.size; canvas.drawCircle( size.center(ui.Offset.zero), size.shortestSide * 0.45, - new ui.Paint()..color = color + ui.Paint()..color = color ); // When we're done issuing painting commands, we end the recording an receive @@ -46,7 +46,7 @@ final double devicePixelRatio = ui.window.devicePixelRatio; // This transform scales the x and y coordinates by the devicePixelRatio. - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 @@ -56,7 +56,7 @@ // transform that scale its children by the device pixel ratio. This transform // lets us paint in "logical" pixels which are converted to device pixels by // this scaling operation. - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop();
diff --git a/examples/layers/rendering/custom_coordinate_systems.dart b/examples/layers/rendering/custom_coordinate_systems.dart index c1dd8ce..208bcf1 100644 --- a/examples/layers/rendering/custom_coordinate_systems.dart +++ b/examples/layers/rendering/custom_coordinate_systems.dart
@@ -9,17 +9,17 @@ import 'src/sector_layout.dart'; RenderBox buildSectorExample() { - final RenderSectorRing rootCircle = new RenderSectorRing(padding: 20.0); - rootCircle.add(new RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15)); - rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); - final RenderSectorSlice stack = new RenderSectorSlice(padding: 2.0); - stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0)); - stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0)); - stack.add(new RenderSolidColor(const Color(0xFF00FF00))); + final RenderSectorRing rootCircle = RenderSectorRing(padding: 20.0); + rootCircle.add(RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15)); + rootCircle.add(RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); + final RenderSectorSlice stack = RenderSectorSlice(padding: 2.0); + stack.add(RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0)); + stack.add(RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0)); + stack.add(RenderSolidColor(const Color(0xFF00FF00))); rootCircle.add(stack); - return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); + return RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); } void main() { - new RenderingFlutterBinding(root: buildSectorExample()); + RenderingFlutterBinding(root: buildSectorExample()); }
diff --git a/examples/layers/rendering/flex_layout.dart b/examples/layers/rendering/flex_layout.dart index 3ed89fe..5965520 100644 --- a/examples/layers/rendering/flex_layout.dart +++ b/examples/layers/rendering/flex_layout.dart
@@ -10,42 +10,42 @@ import 'src/solid_color_box.dart'; void main() { - final RenderFlex table = new RenderFlex(direction: Axis.vertical, textDirection: TextDirection.ltr); + final RenderFlex table = RenderFlex(direction: Axis.vertical, textDirection: TextDirection.ltr); void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) { TextStyle style = const TextStyle(color: Color(0xFF000000)); - final RenderParagraph paragraph = new RenderParagraph( - new TextSpan(style: style, text: '$crossAxisAlignment'), + final RenderParagraph paragraph = RenderParagraph( + TextSpan(style: style, text: '$crossAxisAlignment'), textDirection: TextDirection.ltr, ); - table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); - final RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); + table.add(RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); + final RenderFlex row = RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); style = const TextStyle(fontSize: 15.0, color: Color(0xFF000000)); - row.add(new RenderDecoratedBox( + row.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FFFCCCC)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo'), textDirection: TextDirection.ltr, ), )); style = const TextStyle(fontSize: 10.0, color: Color(0xFF000000)); - row.add(new RenderDecoratedBox( + row.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FCCFFCC)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo'), textDirection: TextDirection.ltr, ), )); - final RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); + final RenderFlex subrow = RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); style = const TextStyle(fontSize: 25.0, color: Color(0xFF000000)); - subrow.add(new RenderDecoratedBox( + subrow.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FCCCCFF)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo foo'), textDirection: TextDirection.ltr, ), )); - subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0))); + subrow.add(RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0))); row.add(subrow); table.add(row); final FlexParentData rowParentData = row.parentData; @@ -60,15 +60,15 @@ void addJustificationRow(MainAxisAlignment justify) { const TextStyle style = TextStyle(color: Color(0xFF000000)); - final RenderParagraph paragraph = new RenderParagraph( - new TextSpan(style: style, text: '$justify'), + final RenderParagraph paragraph = RenderParagraph( + TextSpan(style: style, text: '$justify'), textDirection: TextDirection.ltr, ); - table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); - final RenderFlex row = new RenderFlex(direction: Axis.horizontal, textDirection: TextDirection.ltr); - 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))); + table.add(RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); + final RenderFlex row = RenderFlex(direction: Axis.horizontal, textDirection: TextDirection.ltr); + row.add(RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.0, 60.0))); + row.add(RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: const Size(64.0, 60.0))); + row.add(RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0))); row.mainAxisAlignment = justify; table.add(row); final FlexParentData rowParentData = row.parentData; @@ -81,10 +81,10 @@ addJustificationRow(MainAxisAlignment.spaceBetween); addJustificationRow(MainAxisAlignment.spaceAround); - final RenderDecoratedBox root = new RenderDecoratedBox( + final RenderDecoratedBox root = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xFFFFFFFF)), - child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)), + child: RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)), ); - new RenderingFlutterBinding(root: root); + RenderingFlutterBinding(root: root); }
diff --git a/examples/layers/rendering/hello_world.dart b/examples/layers/rendering/hello_world.dart index 8480158..1f49ca7 100644 --- a/examples/layers/rendering/hello_world.dart +++ b/examples/layers/rendering/hello_world.dart
@@ -9,14 +9,14 @@ void main() { // We use RenderingFlutterBinding to attach the render tree to the window. - new RenderingFlutterBinding( + RenderingFlutterBinding( // The root of our render tree is a RenderPositionedBox, which centers its // child both vertically and horizontally. - root: new RenderPositionedBox( + root: RenderPositionedBox( alignment: Alignment.center, // We use a RenderParagraph to display the text 'Hello, world.' without // any explicit styling. - child: new RenderParagraph( + child: RenderParagraph( const TextSpan(text: 'Hello, world.'), // The text is in English so we specify the text direction as // left-to-right. If the text had been in Hebrew or Arabic, we would
diff --git a/examples/layers/rendering/spinning_square.dart b/examples/layers/rendering/spinning_square.dart index a611dfa..52f6afb 100644 --- a/examples/layers/rendering/spinning_square.dart +++ b/examples/layers/rendering/spinning_square.dart
@@ -14,17 +14,17 @@ class NonStopVSync implements TickerProvider { const NonStopVSync(); @override - Ticker createTicker(TickerCallback onTick) => new Ticker(onTick); + Ticker createTicker(TickerCallback onTick) => Ticker(onTick); } void main() { // We first create a render object that represents a green box. - final RenderBox green = new RenderDecoratedBox( + final RenderBox green = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xFF00FF00)) ); // Second, we wrap that green box in a render object that forces the green box // to have a specific size. - final RenderBox square = new RenderConstrainedBox( + final RenderBox square = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0), child: green ); @@ -32,29 +32,29 @@ // transform before painting its child. Each frame of the animation, we'll // update the transform of this render object to cause the green square to // spin. - final RenderTransform spin = new RenderTransform( - transform: new Matrix4.identity(), + final RenderTransform spin = RenderTransform( + transform: Matrix4.identity(), alignment: Alignment.center, child: square ); // Finally, we center the spinning green square... - final RenderBox root = new RenderPositionedBox( + final RenderBox root = RenderPositionedBox( alignment: Alignment.center, child: spin ); // and attach it to the window. - new RenderingFlutterBinding(root: root); + RenderingFlutterBinding(root: root); // To make the square spin, we use an animation that repeats every 1800 // milliseconds. - final AnimationController animation = new AnimationController( + final AnimationController animation = AnimationController( duration: const Duration(milliseconds: 1800), vsync: const NonStopVSync(), )..repeat(); // The animation will produce a value between 0.0 and 1.0 each frame, but we // want to rotate the square using a value between 0.0 and math.pi. To change // the range of the animation, we use a Tween. - final Tween<double> tween = new Tween<double>(begin: 0.0, end: math.pi); + final Tween<double> tween = Tween<double>(begin: 0.0, end: math.pi); // We add a listener to the animation, which will be called every time the // animation ticks. animation.addListener(() { @@ -63,6 +63,6 @@ // of the animation. Setting this value will mark a number of dirty bits // inside the render tree, which cause the render tree to repaint with the // new transform value this frame. - spin.transform = new Matrix4.rotationZ(tween.evaluate(animation)); + spin.transform = Matrix4.rotationZ(tween.evaluate(animation)); }); }
diff --git a/examples/layers/rendering/src/sector_layout.dart b/examples/layers/rendering/src/sector_layout.dart index 214089a..0cbf123 100644 --- a/examples/layers/rendering/src/sector_layout.dart +++ b/examples/layers/rendering/src/sector_layout.dart
@@ -60,7 +60,7 @@ SectorConstraints constraints, { double deltaRadius = 0.0, double deltaTheta = 0.0 } ) { - return new SectorDimensions( + return SectorDimensions( deltaRadius: constraints.constrainDeltaRadius(deltaRadius), deltaTheta: constraints.constrainDeltaTheta(deltaTheta) ); @@ -80,7 +80,7 @@ @override void setupParentData(RenderObject child) { if (child.parentData is! SectorParentData) - child.parentData = new SectorParentData(); + child.parentData = SectorParentData(); } // RenderSectors always use SectorParentData subclasses, as they need to be @@ -89,7 +89,7 @@ SectorParentData get parentData => super.parentData; SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { - return new SectorDimensions.withConstraints(constraints); + return SectorDimensions.withConstraints(constraints); } @override @@ -124,17 +124,17 @@ } @override - Rect get paintBounds => new Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius); + Rect get paintBounds => Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius); @override - Rect get semanticBounds => new Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius); + Rect get semanticBounds => Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius); bool hitTest(HitTestResult result, { double radius, double theta }) { if (radius < parentData.radius || radius >= parentData.radius + deltaRadius || theta < parentData.theta || theta >= parentData.theta + deltaTheta) return false; hitTestChildren(result, radius: radius, theta: theta); - result.add(new HitTestEntry(this)); + result.add(HitTestEntry(this)); return true; } void hitTestChildren(HitTestResult result, { double radius, double theta }) { } @@ -168,13 +168,13 @@ if (_decoration.color != null) { final Canvas canvas = context.canvas; - final Paint paint = new Paint()..color = _decoration.color; - final Path path = new Path(); + final Paint paint = Paint()..color = _decoration.color; + final Path path = Path(); final double outerRadius = parentData.radius + deltaRadius; - final Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); + final Rect outerBounds = Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); path.arcTo(outerBounds, parentData.theta, deltaTheta, true); final double innerRadius = parentData.radius; - final Rect innerBounds = new Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius); + final Rect innerBounds = Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius); path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false); path.close(); canvas.drawPath(path, paint); @@ -248,7 +248,7 @@ void setupParentData(RenderObject child) { // TODO(ianh): avoid code duplication if (child.parentData is! SectorChildListParentData) - child.parentData = new SectorChildListParentData(); + child.parentData = SectorChildListParentData(); } @override @@ -261,7 +261,7 @@ double remainingDeltaTheta = math.max(0.0, constraints.maxDeltaTheta - (innerTheta + paddingTheta)); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: innerDeltaRadius, maxDeltaTheta: remainingDeltaTheta ); @@ -275,7 +275,7 @@ remainingDeltaTheta -= paddingTheta; } } - return new SectorDimensions.withConstraints(constraints, + return SectorDimensions.withConstraints(constraints, deltaRadius: outerDeltaRadius, deltaTheta: innerTheta); } @@ -292,7 +292,7 @@ double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: innerDeltaRadius, maxDeltaTheta: remainingDeltaTheta ); @@ -362,7 +362,7 @@ void setupParentData(RenderObject child) { // TODO(ianh): avoid code duplication if (child.parentData is! SectorChildListParentData) - child.parentData = new SectorChildListParentData(); + child.parentData = SectorChildListParentData(); } @override @@ -375,7 +375,7 @@ double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: remainingDeltaRadius, maxDeltaTheta: innerDeltaTheta ); @@ -387,7 +387,7 @@ childRadius += padding; remainingDeltaRadius -= padding; } - return new SectorDimensions.withConstraints(constraints, + return SectorDimensions.withConstraints(constraints, deltaRadius: childRadius - parentData.radius, deltaTheta: outerDeltaTheta); } @@ -404,7 +404,7 @@ double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: remainingDeltaRadius, maxDeltaTheta: innerDeltaTheta ); @@ -455,7 +455,7 @@ @override void setupParentData(RenderObject child) { if (child.parentData is! SectorParentData) - child.parentData = new SectorParentData(); + child.parentData = SectorParentData(); } @override @@ -497,9 +497,9 @@ if (!width.isFinite && !height.isFinite) return Size.zero; final double maxChildDeltaRadius = math.max(0.0, math.min(width, height) / 2.0 - innerRadius); - final SectorDimensions childDimensions = child.getIntrinsicDimensions(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius); + final SectorDimensions childDimensions = child.getIntrinsicDimensions(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius); final double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0; - return new Size.square(dimension); + return Size.square(dimension); } @override @@ -513,9 +513,9 @@ final double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius; child.parentData.radius = innerRadius; child.parentData.theta = 0.0; - child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true); + child.layout(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true); final double dimension = (innerRadius + child.deltaRadius) * 2.0; - size = constraints.constrain(new Size(dimension, dimension)); + size = constraints.constrain(Size(dimension, dimension)); } @override @@ -547,7 +547,7 @@ if (theta > child.deltaTheta) return false; child.hitTest(result, radius: radius, theta: theta); - result.add(new BoxHitTestEntry(this, position)); + result.add(BoxHitTestEntry(this, position)); return true; } @@ -557,7 +557,7 @@ RenderSolidColor(this.backgroundColor, { this.desiredDeltaRadius = double.infinity, this.desiredDeltaTheta = kTwoPi - }) : super(new BoxDecoration(color: backgroundColor)); + }) : super(BoxDecoration(color: backgroundColor)); double desiredDeltaRadius; double desiredDeltaTheta; @@ -565,7 +565,7 @@ @override SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { - return new SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta); + return SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta); } @override @@ -579,7 +579,7 @@ if (event is PointerDownEvent) { decoration = const BoxDecoration(color: Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(color: backgroundColor); + decoration = BoxDecoration(color: backgroundColor); } } }
diff --git a/examples/layers/rendering/src/solid_color_box.dart b/examples/layers/rendering/src/solid_color_box.dart index b34faac..419d181 100644 --- a/examples/layers/rendering/src/solid_color_box.dart +++ b/examples/layers/rendering/src/solid_color_box.dart
@@ -10,7 +10,7 @@ final Color backgroundColor; RenderSolidColorBox(this.backgroundColor, { this.desiredSize = Size.infinite }) - : super(decoration: new BoxDecoration(color: backgroundColor)); + : super(decoration: BoxDecoration(color: backgroundColor)); @override double computeMinIntrinsicWidth(double height) { @@ -42,7 +42,7 @@ if (event is PointerDownEvent) { decoration = const BoxDecoration(color: Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(color: backgroundColor); + decoration = BoxDecoration(color: backgroundColor); } } }
diff --git a/examples/layers/rendering/touch_input.dart b/examples/layers/rendering/touch_input.dart index d766a5e..aa914b9 100644 --- a/examples/layers/rendering/touch_input.dart +++ b/examples/layers/rendering/touch_input.dart
@@ -20,7 +20,7 @@ /// A simple model object for a dot that reacts to pointer pressure. class Dot { - Dot({ Color color }) : _paint = new Paint()..color = color; + Dot({ Color color }) : _paint = Paint()..color = color; final Paint _paint; Offset position = Offset.zero; @@ -66,7 +66,7 @@ void handleEvent(PointerEvent event, BoxHitTestEntry entry) { if (event is PointerDownEvent) { final Color color = _kColors[event.pointer.remainder(_kColors.length)]; - _dots[event.pointer] = new Dot(color: color)..update(event); + _dots[event.pointer] = Dot(color: color)..update(event); // We call markNeedsPaint to indicate that our painting commands have // changed and that paint needs to be called before displaying a new frame // to the user. It's harmless to call markNeedsPaint multiple times @@ -91,7 +91,7 @@ // Passing offset during the render tree's paint walk is an optimization to // avoid having to change the origin of the canvas's coordinate system too // often. - canvas.drawRect(offset & size, new Paint()..color = const Color(0xFFFFFFFF)); + canvas.drawRect(offset & size, Paint()..color = const Color(0xFFFFFFFF)); // We iterate through our model and paint each dot. for (Dot dot in _dots.values) @@ -101,7 +101,7 @@ void main() { // Create some styled text to tell the user to interact with the app. - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( style: TextStyle(color: Colors.black87), text: 'Touch me!', @@ -111,10 +111,10 @@ // A stack is a render object that layers its children on top of each other. // The bottom later is our RenderDots object, and on top of that we show the // text. - final RenderStack stack = new RenderStack( + final RenderStack stack = RenderStack( textDirection: TextDirection.ltr, children: <RenderBox>[ - new RenderDots(), + RenderDots(), paragraph, ], ); @@ -132,5 +132,5 @@ ..left = 20.0; // Finally, we attach the render tree we've built to the screen. - new RenderingFlutterBinding(root: stack); + RenderingFlutterBinding(root: stack); }
diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index c4c7fd2..0536aee 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart
@@ -36,7 +36,7 @@ // Run the computation associated with this Calculator. void run() { int i = 0; - final JsonDecoder decoder = new JsonDecoder( + final JsonDecoder decoder = JsonDecoder( (dynamic key, dynamic value) { if (key is int && i++ % _NOTIFY_INTERVAL == 0) onProgressListener(i.toDouble(), _NUM_ITEMS.toDouble()); @@ -54,7 +54,7 @@ } static String _replicateJson(String data, int count) { - final StringBuffer buffer = new StringBuffer()..write('['); + final StringBuffer buffer = StringBuffer()..write('['); for (int i = 0; i < count; i++) { buffer.write(data); if (i < count - 1) @@ -88,7 +88,7 @@ CalculationManager({ @required this.onProgressListener, @required this.onResultListener }) : assert(onProgressListener != null), assert(onResultListener != null), - _receivePort = new ReceivePort() { + _receivePort = ReceivePort() { _receivePort.listen(_handleMessage); } @@ -138,7 +138,7 @@ // loaded. rootBundle.loadString('services/data.json').then<Null>((String data) { if (isRunning) { - final CalculationMessage message = new CalculationMessage(data, _receivePort.sendPort); + final CalculationMessage message = CalculationMessage(data, _receivePort.sendPort); // Spawn an isolate to JSON-parse the file contents. The JSON parsing // is synchronous, so if done in the main isolate, the UI would block. Isolate.spawn(_calculate, message).then<Null>((Isolate isolate) { @@ -178,7 +178,7 @@ // in a separate memory space. static void _calculate(CalculationMessage message) { final SendPort sender = message.sendPort; - final Calculator calculator = new Calculator( + final Calculator calculator = Calculator( onProgressListener: (double completed, double total) { sender.send(<double>[ completed, total ]); }, @@ -199,7 +199,7 @@ // the AnimationController for the running animation. class IsolateExampleWidget extends StatefulWidget { @override - IsolateExampleState createState() => new IsolateExampleState(); + IsolateExampleState createState() => IsolateExampleState(); } // Main application state. @@ -215,11 +215,11 @@ @override void initState() { super.initState(); - _animation = new AnimationController( + _animation = AnimationController( duration: const Duration(milliseconds: 3600), vsync: this, )..repeat(); - _calculationManager = new CalculationManager( + _calculationManager = CalculationManager( onProgressListener: _handleProgressUpdate, onResultListener: _handleResult ); @@ -233,32 +233,32 @@ @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ - new RotationTransition( + RotationTransition( turns: _animation, - child: new Container( + child: Container( width: 120.0, height: 120.0, color: const Color(0xFF882222), ) ), - new Opacity( + Opacity( opacity: _calculationManager.isRunning ? 1.0 : 0.0, - child: new CircularProgressIndicator( + child: CircularProgressIndicator( value: _progress ) ), - new Text(_status), - new Center( - child: new RaisedButton( - child: new Text(_label), + Text(_status), + Center( + child: RaisedButton( + child: Text(_label), onPressed: _handleButtonPressed ) ), - new Text(_result) + Text(_result) ] ) ); @@ -303,5 +303,5 @@ } void main() { - runApp(new MaterialApp(home: new IsolateExampleWidget())); + runApp(MaterialApp(home: IsolateExampleWidget())); }
diff --git a/examples/layers/services/lifecycle.dart b/examples/layers/services/lifecycle.dart index 36f3c50..ab3bda2 100644 --- a/examples/layers/services/lifecycle.dart +++ b/examples/layers/services/lifecycle.dart
@@ -8,7 +8,7 @@ const LifecycleWatcher({ Key key }) : super(key: key); @override - _LifecycleWatcherState createState() => new _LifecycleWatcherState(); + _LifecycleWatcherState createState() => _LifecycleWatcherState(); } class _LifecycleWatcherState extends State<LifecycleWatcher> @@ -38,7 +38,7 @@ Widget build(BuildContext context) { if (_lastLifecycleState == null) return const Text('This widget has not observed any lifecycle changes.'); - return new Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.'); + return Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.'); } }
diff --git a/examples/layers/test/gestures_test.dart b/examples/layers/test/gestures_test.dart index 902385a..c37b1d2 100644 --- a/examples/layers/test/gestures_test.dart +++ b/examples/layers/test/gestures_test.dart
@@ -9,9 +9,9 @@ void main() { testWidgets('Tap on center change color', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new GestureDemo(), + child: GestureDemo(), )); final Finder finder = find.byType(GestureDemo);
diff --git a/examples/layers/test/sector_test.dart b/examples/layers/test/sector_test.dart index 3903e9d..0207f18 100644 --- a/examples/layers/test/sector_test.dart +++ b/examples/layers/test/sector_test.dart
@@ -13,6 +13,6 @@ }); testWidgets('Sector Sixes', (WidgetTester tester) async { - await tester.pumpWidget(new SectorApp()); + await tester.pumpWidget(SectorApp()); }); }
diff --git a/examples/layers/widgets/custom_render_box.dart b/examples/layers/widgets/custom_render_box.dart index cd7c78b..2a5f832 100644 --- a/examples/layers/widgets/custom_render_box.dart +++ b/examples/layers/widgets/custom_render_box.dart
@@ -28,9 +28,9 @@ @override void paint(PaintingContext context, Offset offset) { final Canvas canvas = context.canvas; - canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF)); + canvas.drawRect(offset & size, Paint()..color = const Color(0xFF0000FF)); - final Paint paint = new Paint()..color = const Color(0xFF00FF00); + final Paint paint = Paint()..color = const Color(0xFF00FF00); for (Offset point in _dots.values) canvas.drawCircle(point, 50.0, paint); @@ -42,7 +42,7 @@ const Dots({ Key key, Widget child }) : super(key: key, child: child); @override - RenderDots createRenderObject(BuildContext context) => new RenderDots(); + RenderDots createRenderObject(BuildContext context) => RenderDots(); } void main() {
diff --git a/examples/layers/widgets/gestures.dart b/examples/layers/widgets/gestures.dart index c751399..1e884a9 100644 --- a/examples/layers/widgets/gestures.dart +++ b/examples/layers/widgets/gestures.dart
@@ -29,12 +29,12 @@ void paint(Canvas canvas, Size size) { final Offset center = size.center(Offset.zero) * zoom + offset; final double radius = size.width / 2.0 * zoom; - final Gradient gradient = new RadialGradient( + final Gradient gradient = RadialGradient( colors: forward ? <Color>[swatch.shade50, swatch.shade900] : <Color>[swatch.shade900, swatch.shade50] ); - final Paint paint = new Paint() - ..shader = gradient.createShader(new Rect.fromCircle( + final Paint paint = Paint() + ..shader = gradient.createShader(Rect.fromCircle( center: center, radius: radius, )); @@ -56,7 +56,7 @@ class GestureDemo extends StatefulWidget { @override - GestureDemoState createState() => new GestureDemoState(); + GestureDemoState createState() => GestureDemoState(); } class GestureDemoState extends State<GestureDemo> { @@ -141,17 +141,17 @@ @override Widget build(BuildContext context) { - return new Stack( + return Stack( fit: StackFit.expand, children: <Widget>[ - new GestureDetector( + GestureDetector( onScaleStart: _scaleEnabled ? _handleScaleStart : null, onScaleUpdate: _scaleEnabled ? _handleScaleUpdate : null, onTap: _tapEnabled ? _handleColorChange : null, onDoubleTap: _doubleTapEnabled ? _handleScaleReset : null, onLongPress: _longPressEnabled ? _handleDirectionChange : null, - child: new CustomPaint( - painter: new _GesturePainter( + child: CustomPaint( + painter: _GesturePainter( zoom: _zoom, offset: _offset, swatch: swatch, @@ -163,44 +163,44 @@ ) ) ), - new Positioned( + Positioned( bottom: 0.0, left: 0.0, - child: new Card( - child: new Container( + child: Card( + child: Container( padding: const EdgeInsets.all(4.0), - child: new Column( + child: Column( children: <Widget>[ - new Row( + Row( children: <Widget>[ - new Checkbox( + Checkbox( value: _scaleEnabled, onChanged: (bool value) { setState(() { _scaleEnabled = value; }); } ), const Text('Scale'), ] ), - new Row( + Row( children: <Widget>[ - new Checkbox( + Checkbox( value: _tapEnabled, onChanged: (bool value) { setState(() { _tapEnabled = value; }); } ), const Text('Tap'), ] ), - new Row( + Row( children: <Widget>[ - new Checkbox( + Checkbox( value: _doubleTapEnabled, onChanged: (bool value) { setState(() { _doubleTapEnabled = value; }); } ), const Text('Double Tap'), ] ), - new Row( + Row( children: <Widget>[ - new Checkbox( + Checkbox( value: _longPressEnabled, onChanged: (bool value) { setState(() { _longPressEnabled = value; }); } ), @@ -219,11 +219,11 @@ } void main() { - runApp(new MaterialApp( - theme: new ThemeData.dark(), - home: new Scaffold( - appBar: new AppBar(title: const Text('Gestures Demo')), - body: new GestureDemo() + runApp(MaterialApp( + theme: ThemeData.dark(), + home: Scaffold( + appBar: AppBar(title: const Text('Gestures Demo')), + body: GestureDemo() ) )); }
diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index ef929b8..69ed7f3 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart
@@ -11,15 +11,15 @@ @override Widget build(BuildContext context) { - return new Row( + return Row( children: <Widget>[ - new Container( + Container( width: 32.0, height: 32.0, margin: const EdgeInsets.all(8.0), color: Colors.lightBlueAccent.shade100, ), - new Text(name) + Text(name) ] ); } @@ -32,20 +32,20 @@ @override Widget build(BuildContext context) { - return new Card( - child: new Column( + return Card( + child: Column( children: <Widget>[ - new Expanded( - child: new Container( + Expanded( + child: Container( color: Colors.lightBlueAccent.shade100, ) ), - new Container( + Container( margin: const EdgeInsets.only(left: 8.0), - child: new Row( + child: Row( children: <Widget>[ - new Expanded( - child: new Text(name) + Expanded( + child: Text(name) ), const IconButton( icon: Icon(Icons.more_vert), @@ -72,14 +72,14 @@ @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) { - return new ListView( + return ListView( itemExtent: _kListItemExtent, - children: names.map((String name) => new AdaptedListItem(name: name)).toList(), + children: names.map((String name) => AdaptedListItem(name: name)).toList(), ); } else { - return new GridView.extent( + return GridView.extent( maxCrossAxisExtent: _kMaxTileWidth, - children: names.map((String name) => new AdaptedGridItem(name: name)).toList(), + children: names.map((String name) => AdaptedGridItem(name: name)).toList(), ); } } @@ -95,13 +95,13 @@ final List<String> _kNames = _initNames(); void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Media Query Example', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Media Query Example') ), - body: new Material(child: new AdaptiveContainer(names: _kNames)) + body: Material(child: AdaptiveContainer(names: _kNames)) ) )); }
diff --git a/examples/layers/widgets/sectors.dart b/examples/layers/widgets/sectors.dart index 85e7de4..b8fae26 100644 --- a/examples/layers/widgets/sectors.dart +++ b/examples/layers/widgets/sectors.dart
@@ -10,21 +10,21 @@ import '../rendering/src/sector_layout.dart'; RenderBox initCircle() { - return new RenderBoxToRenderSectorAdapter( + return RenderBoxToRenderSectorAdapter( innerRadius: 25.0, - child: new RenderSectorRing(padding: 0.0) + child: RenderSectorRing(padding: 0.0) ); } class SectorApp extends StatefulWidget { @override - SectorAppState createState() => new SectorAppState(); + SectorAppState createState() => SectorAppState(); } class SectorAppState extends State<SectorApp> { final RenderBoxToRenderSectorAdapter sectors = initCircle(); - final math.Random rand = new math.Random(1); + final math.Random rand = math.Random(1); List<double> wantedSectorSizes = <double>[]; List<double> actualSectorSizes = <double>[]; @@ -60,19 +60,19 @@ actualSectorSizes.removeLast(); } while (index < wantedSectorSizes.length) { - final Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); - ring.add(new RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index])); + final Color color = Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); + ring.add(RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index])); actualSectorSizes.add(wantedSectorSizes[index]); index += 1; } } static RenderBox initSector(Color color) { - final RenderSectorRing ring = new RenderSectorRing(padding: 1.0); - ring.add(new RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); - ring.add(new RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); - ring.add(new RenderSolidColor(color, desiredDeltaTheta: kTwoPi * 0.2)); - return new RenderBoxToRenderSectorAdapter( + final RenderSectorRing ring = RenderSectorRing(padding: 1.0); + ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); + ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); + ring.add(RenderSolidColor(color, desiredDeltaTheta: kTwoPi * 0.2)); + return RenderBoxToRenderSectorAdapter( innerRadius: 5.0, child: ring ); @@ -90,36 +90,36 @@ } Widget buildBody() { - return new Column( + return Column( children: <Widget>[ - new Container( + Container( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 25.0), - child: new Row( + child: Row( children: <Widget>[ - new RaisedButton( + RaisedButton( onPressed: _enabledAdd ? addSector : null, - child: new IntrinsicWidth( - child: new Row( + child: IntrinsicWidth( + child: Row( children: <Widget>[ - new Container( + Container( padding: const EdgeInsets.all(4.0), margin: const EdgeInsets.only(right: 10.0), - child: new WidgetToRenderBoxAdapter(renderBox: sectorAddIcon) + child: WidgetToRenderBoxAdapter(renderBox: sectorAddIcon) ), const Text('ADD SECTOR'), ] ) ) ), - new RaisedButton( + RaisedButton( onPressed: _enabledRemove ? removeSector : null, - child: new IntrinsicWidth( - child: new Row( + child: IntrinsicWidth( + child: Row( children: <Widget>[ - new Container( + Container( padding: const EdgeInsets.all(4.0), margin: const EdgeInsets.only(right: 10.0), - child: new WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon) + child: WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon) ), const Text('REMOVE SECTOR'), ] @@ -130,14 +130,14 @@ mainAxisAlignment: MainAxisAlignment.spaceAround ) ), - new Expanded( - child: new Container( + Expanded( + child: Container( margin: const EdgeInsets.all(8.0), - decoration: new BoxDecoration( - border: new Border.all() + decoration: BoxDecoration( + border: Border.all() ), padding: const EdgeInsets.all(8.0), - child: new WidgetToRenderBoxAdapter( + child: WidgetToRenderBoxAdapter( renderBox: sectors, onBuild: doUpdates ) @@ -150,11 +150,11 @@ @override Widget build(BuildContext context) { - return new MaterialApp( - theme: new ThemeData.light(), + return MaterialApp( + theme: ThemeData.light(), title: 'Sector Layout', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Sector Layout in a Widget Tree') ), body: buildBody() @@ -164,5 +164,5 @@ } void main() { - runApp(new SectorApp()); + runApp(SectorApp()); }
diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index aaf4eb6..4801ac7 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart
@@ -9,7 +9,7 @@ // Solid colour, RenderObject version void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex = 0 }) { - final RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor); + final RenderSolidColorBox child = RenderSolidColorBox(backgroundColor); parent.add(child); final FlexParentData childParentData = child.parentData; childParentData.flex = flex; @@ -23,8 +23,8 @@ @override Widget build(BuildContext context) { - return new Expanded( - child: new Container( + return Expanded( + child: Container( color: color, ) ); @@ -33,27 +33,27 @@ double value; RenderObjectToWidgetElement<RenderBox> element; -BuildOwner owner = new BuildOwner(); +BuildOwner owner = BuildOwner(); void attachWidgetTreeToRenderTree(RenderProxyBox container) { - element = new RenderObjectToWidgetAdapter<RenderBox>( + element = RenderObjectToWidgetAdapter<RenderBox>( container: container, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new Container( + child: Container( height: 300.0, - child: new Column( + child: Column( children: <Widget>[ const Rectangle(Color(0xFF00FFFF)), - new Material( - child: new Container( + Material( + child: Container( padding: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0), - child: new Row( + child: Row( children: <Widget>[ - new RaisedButton( - child: new Row( + RaisedButton( + child: Row( children: <Widget>[ - new Image.network('https://flutter.io/images/favicon.png'), + Image.network('https://flutter.io/images/favicon.png'), const Text('PRESS ME'), ], ), @@ -62,7 +62,7 @@ attachWidgetTreeToRenderTree(container); }, ), - new CircularProgressIndicator(value: value), + CircularProgressIndicator(value: value), ], mainAxisAlignment: MainAxisAlignment.spaceAround, ), @@ -92,16 +92,16 @@ void main() { final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized(); - final RenderProxyBox proxy = new RenderProxyBox(); + final RenderProxyBox proxy = RenderProxyBox(); attachWidgetTreeToRenderTree(proxy); - final RenderFlex flexRoot = new RenderFlex(direction: Axis.vertical); + final RenderFlex flexRoot = RenderFlex(direction: Axis.vertical); addFlexChildSolidColor(flexRoot, const Color(0xFFFF00FF), flex: 1); flexRoot.add(proxy); addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1); - transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: Alignment.center); - final RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox); + transformBox = RenderTransform(child: flexRoot, transform: Matrix4.identity(), alignment: Alignment.center); + final RenderPadding root = RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox); binding.renderView.child = root; binding.addPersistentFrameCallback(rotate);
diff --git a/examples/layers/widgets/spinning_square.dart b/examples/layers/widgets/spinning_square.dart index 81312d6..6539ffc 100644 --- a/examples/layers/widgets/spinning_square.dart +++ b/examples/layers/widgets/spinning_square.dart
@@ -6,7 +6,7 @@ class SpinningSquare extends StatefulWidget { @override - _SpinningSquareState createState() => new _SpinningSquareState(); + _SpinningSquareState createState() => _SpinningSquareState(); } class _SpinningSquareState extends State<SpinningSquare> with SingleTickerProviderStateMixin { @@ -18,7 +18,7 @@ // We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0 // represents an entire turn of the square whereas in the other examples // we used 0.0 -> math.pi, which is only half a turn. - _animation = new AnimationController( + _animation = AnimationController( duration: const Duration(milliseconds: 3600), vsync: this, )..repeat(); @@ -32,9 +32,9 @@ @override Widget build(BuildContext context) { - return new RotationTransition( + return RotationTransition( turns: _animation, - child: new Container( + child: Container( width: 200.0, height: 200.0, color: const Color(0xFF00FF00), @@ -44,5 +44,5 @@ } void main() { - runApp(new Center(child: new SpinningSquare())); + runApp(Center(child: SpinningSquare())); }
diff --git a/examples/layers/widgets/styled_text.dart b/examples/layers/widgets/styled_text.dart index e8cf81c..0694aa2 100644 --- a/examples/layers/widgets/styled_text.dart +++ b/examples/layers/widgets/styled_text.dart
@@ -23,8 +23,8 @@ .map((String line) => line.split(':')) .toList(); -final TextStyle _kDaveStyle = new TextStyle(color: Colors.indigo.shade400, height: 1.8); -final TextStyle _kHalStyle = new TextStyle(color: Colors.red.shade400, fontFamily: 'monospace'); +final TextStyle _kDaveStyle = TextStyle(color: Colors.indigo.shade400, height: 1.8); +final TextStyle _kHalStyle = TextStyle(color: Colors.red.shade400, fontFamily: 'monospace'); const TextStyle _kBold = TextStyle(fontWeight: FontWeight.bold); const TextStyle _kUnderline = TextStyle( decoration: TextDecoration.underline, @@ -34,33 +34,33 @@ Widget toStyledText(String name, String text) { final TextStyle lineStyle = (name == 'Dave') ? _kDaveStyle : _kHalStyle; - return new RichText( - key: new Key(text), - text: new TextSpan( + return RichText( + key: Key(text), + text: TextSpan( style: lineStyle, children: <TextSpan>[ - new TextSpan( + TextSpan( style: _kBold, children: <TextSpan>[ - new TextSpan( + TextSpan( style: _kUnderline, text: name ), const TextSpan(text: ':') ] ), - new TextSpan(text: text) + TextSpan(text: text) ] ) ); } -Widget toPlainText(String name, String text) => new Text(name + ':' + text); +Widget toPlainText(String name, String text) => Text(name + ':' + text); class SpeakerSeparator extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( constraints: const BoxConstraints.expand(height: 0.0), margin: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 64.0), decoration: const BoxDecoration( @@ -74,7 +74,7 @@ class StyledTextDemo extends StatefulWidget { @override - _StyledTextDemoState createState() => new _StyledTextDemoState(); + _StyledTextDemoState createState() => _StyledTextDemoState(); } class _StyledTextDemoState extends State<StyledTextDemo> { @@ -102,14 +102,14 @@ for (Widget line in lines) { children.add(line); if (line != lines.last) - children.add(new SpeakerSeparator()); + children.add(SpeakerSeparator()); } - return new GestureDetector( + return GestureDetector( onTap: _handleTap, - child: new Container( + child: Container( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Column( + child: Column( children: children, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start @@ -120,15 +120,15 @@ } void main() { - runApp(new MaterialApp( - theme: new ThemeData.light(), - home: new Scaffold( - appBar: new AppBar( + runApp(MaterialApp( + theme: ThemeData.light(), + home: Scaffold( + appBar: AppBar( title: const Text('Hal and Dave') ), - body: new Material( + body: Material( color: Colors.grey.shade50, - child: new StyledTextDemo() + child: StyledTextDemo() ) ) ));