Commit 4c8c420e authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Declare locals final where not reassigned (layers) (#8572)

parent 96eea437
...@@ -13,21 +13,21 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -13,21 +13,21 @@ ui.Picture paint(ui.Rect paintBounds) {
// First we create a PictureRecorder to record the commands we're going to // First we create a PictureRecorder to record the commands we're going to
// feed in the canvas. The PictureRecorder will eventually produce a Picture, // feed in the canvas. The PictureRecorder will eventually produce a Picture,
// which is an immutable record of those commands. // which is an immutable record of those commands.
ui.PictureRecorder recorder = new ui.PictureRecorder(); final ui.PictureRecorder recorder = new ui.PictureRecorder();
// Next, we create a canvas from the recorder. The canvas is an interface // Next, we create a canvas from the recorder. The canvas is an interface
// which can receive drawing commands. The canvas interface is modeled after // which can receive drawing commands. The canvas interface is modeled after
// the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect"
// for the canvas, which lets the implementation discard any commands that // for the canvas, which lets the implementation discard any commands that
// are entirely outside this rectangle. // are entirely outside this rectangle.
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
ui.Paint paint = new ui.Paint(); final ui.Paint paint = new ui.Paint();
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF)); canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
ui.Size size = paintBounds.size; final ui.Size size = paintBounds.size;
ui.Point mid = size.center(ui.Point.origin); final ui.Point mid = size.center(ui.Point.origin);
double radius = size.shortestSide / 2.0; final double radius = size.shortestSide / 2.0;
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
...@@ -41,7 +41,7 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -41,7 +41,7 @@ ui.Picture paint(ui.Rect paintBounds) {
paint.color = const ui.Color.fromARGB(128, 255, 0, 255); paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
canvas.rotate(math.PI/4.0); canvas.rotate(math.PI/4.0);
ui.Gradient yellowBlue = new ui.Gradient.linear( final ui.Gradient yellowBlue = new ui.Gradient.linear(
<ui.Point>[new ui.Point(-radius, -radius), const 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)] <ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)]
); );
...@@ -49,7 +49,7 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -49,7 +49,7 @@ ui.Picture paint(ui.Rect paintBounds) {
new ui.Paint()..shader = yellowBlue); new ui.Paint()..shader = yellowBlue);
// Scale x and y by 0.5. // Scale x and y by 0.5.
Float64List scaleMatrix = new Float64List.fromList(<double>[ final Float64List scaleMatrix = new Float64List.fromList(<double>[
0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
...@@ -72,12 +72,12 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -72,12 +72,12 @@ ui.Picture paint(ui.Rect paintBounds) {
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
Float64List deviceTransform = new Float64List(16) final Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
..[10] = 1.0 ..[10] = 1.0
..[15] = 1.0; ..[15] = 1.0;
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
..pushTransform(deviceTransform) ..pushTransform(deviceTransform)
..addPicture(ui.Offset.zero, picture) ..addPicture(ui.Offset.zero, picture)
..pop(); ..pop();
...@@ -85,9 +85,9 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -85,9 +85,9 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
} }
void beginFrame(Duration timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio); final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
ui.Picture picture = paint(paintBounds); final ui.Picture picture = paint(paintBounds);
ui.Scene scene = composite(picture, paintBounds); final ui.Scene scene = composite(picture, paintBounds);
ui.window.render(scene); ui.window.render(scene);
} }
......
...@@ -19,29 +19,29 @@ void beginFrame(Duration timeStamp) { ...@@ -19,29 +19,29 @@ void beginFrame(Duration timeStamp) {
// PAINT // PAINT
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio); final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
ui.PictureRecorder recorder = new ui.PictureRecorder(); final ui.PictureRecorder recorder = new ui.PictureRecorder();
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0); canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
// Here we determine the rotation according to the timeStamp given to us by // Here we determine the rotation according to the timeStamp given to us by
// the engine. // the engine.
double t = timeStamp.inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND / 1800.0; final double t = timeStamp.inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND / 1800.0;
canvas.rotate(math.PI * (t % 1.0)); canvas.rotate(math.PI * (t % 1.0));
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.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)); new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
ui.Picture picture = recorder.endRecording(); final ui.Picture picture = recorder.endRecording();
// COMPOSITE // COMPOSITE
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
Float64List deviceTransform = new Float64List(16) final Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
..[10] = 1.0 ..[10] = 1.0
..[15] = 1.0; ..[15] = 1.0;
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
..pushTransform(deviceTransform) ..pushTransform(deviceTransform)
..addPicture(ui.Offset.zero, picture) ..addPicture(ui.Offset.zero, picture)
..pop(); ..pop();
......
...@@ -12,8 +12,8 @@ import 'dart:ui' as ui; ...@@ -12,8 +12,8 @@ import 'dart:ui' as ui;
ui.Paragraph paragraph; ui.Paragraph paragraph;
ui.Picture paint(ui.Rect paintBounds) { ui.Picture paint(ui.Rect paintBounds) {
ui.PictureRecorder recorder = new ui.PictureRecorder(); final ui.PictureRecorder recorder = new ui.PictureRecorder();
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
...@@ -31,12 +31,12 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -31,12 +31,12 @@ ui.Picture paint(ui.Rect paintBounds) {
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
Float64List deviceTransform = new Float64List(16) final Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
..[10] = 1.0 ..[10] = 1.0
..[15] = 1.0; ..[15] = 1.0;
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
..pushTransform(deviceTransform) ..pushTransform(deviceTransform)
..addPicture(ui.Offset.zero, picture) ..addPicture(ui.Offset.zero, picture)
..pop(); ..pop();
...@@ -44,15 +44,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -44,15 +44,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
} }
void beginFrame(Duration timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio); final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
ui.Picture picture = paint(paintBounds); final ui.Picture picture = paint(paintBounds);
ui.Scene scene = composite(picture, paintBounds); final ui.Scene scene = composite(picture, paintBounds);
ui.window.render(scene); ui.window.render(scene);
} }
void main() { void main() {
// To create a paragraph of text, we use ParagraphBuilder. // To create a paragraph of text, we use ParagraphBuilder.
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(new ui.ParagraphStyle()) final ui.ParagraphBuilder builder = new ui.ParagraphBuilder(new ui.ParagraphStyle())
// We first push a style that turns the text blue. // We first push a style that turns the text blue.
..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF))) ..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF)))
..addText('Hello, ') ..addText('Hello, ')
......
...@@ -14,17 +14,17 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -14,17 +14,17 @@ ui.Picture paint(ui.Rect paintBounds) {
// First we create a PictureRecorder to record the commands we're going to // First we create a PictureRecorder to record the commands we're going to
// feed in the canvas. The PictureRecorder will eventually produce a Picture, // feed in the canvas. The PictureRecorder will eventually produce a Picture,
// which is an immutable record of those commands. // which is an immutable record of those commands.
ui.PictureRecorder recorder = new ui.PictureRecorder(); final ui.PictureRecorder recorder = new ui.PictureRecorder();
// Next, we create a canvas from the recorder. The canvas is an interface // Next, we create a canvas from the recorder. The canvas is an interface
// which can receive drawing commands. The canvas interface is modeled after // which can receive drawing commands. The canvas interface is modeled after
// the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect"
// for the canvas, which lets the implementation discard any commands that // for the canvas, which lets the implementation discard any commands that
// are entirely outside this rectangle. // are entirely outside this rectangle.
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
// The commands draw a circle in the center of the screen. // The commands draw a circle in the center of the screen.
ui.Size size = paintBounds.size; final ui.Size size = paintBounds.size;
canvas.drawCircle( canvas.drawCircle(
size.center(ui.Point.origin), size.center(ui.Point.origin),
size.shortestSide * 0.45, size.shortestSide * 0.45,
...@@ -46,7 +46,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -46,7 +46,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.window.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
// This transform scales the x and y coordinates by the devicePixelRatio. // This transform scales the x and y coordinates by the devicePixelRatio.
Float64List deviceTransform = new Float64List(16) final Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
..[10] = 1.0 ..[10] = 1.0
...@@ -56,7 +56,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -56,7 +56,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
// transform that scale its children by the device pixel ratio. This transform // 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 // lets us paint in "logical" pixels which are converted to device pixels by
// this scaling operation. // this scaling operation.
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder()
..pushTransform(deviceTransform) ..pushTransform(deviceTransform)
..addPicture(ui.Offset.zero, picture) ..addPicture(ui.Offset.zero, picture)
..pop(); ..pop();
...@@ -67,11 +67,11 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -67,11 +67,11 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
} }
void beginFrame(Duration timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio); final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
// First, record a picture with our painting commands. // First, record a picture with our painting commands.
ui.Picture picture = paint(paintBounds); final ui.Picture picture = paint(paintBounds);
// Second, include that picture in a scene graph. // Second, include that picture in a scene graph.
ui.Scene scene = composite(picture, paintBounds); final ui.Scene scene = composite(picture, paintBounds);
// Third, instruct the engine to render that scene graph. // Third, instruct the engine to render that scene graph.
ui.window.render(scene); ui.window.render(scene);
} }
......
...@@ -9,10 +9,10 @@ import 'package:flutter/rendering.dart'; ...@@ -9,10 +9,10 @@ import 'package:flutter/rendering.dart';
import 'src/sector_layout.dart'; import 'src/sector_layout.dart';
RenderBox buildSectorExample() { RenderBox buildSectorExample() {
RenderSectorRing rootCircle = new RenderSectorRing(padding: 20.0); 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(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15));
rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4));
RenderSectorSlice stack = new RenderSectorSlice(padding: 2.0); final RenderSectorSlice stack = new RenderSectorSlice(padding: 2.0);
stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.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(0xFFFF9000), desiredDeltaRadius: 20.0));
stack.add(new RenderSolidColor(const Color(0xFF00FF00))); stack.add(new RenderSolidColor(const Color(0xFF00FF00)));
......
...@@ -10,13 +10,13 @@ import 'package:flutter/rendering.dart'; ...@@ -10,13 +10,13 @@ import 'package:flutter/rendering.dart';
import 'src/solid_color_box.dart'; import 'src/solid_color_box.dart';
void main() { void main() {
RenderFlex table = new RenderFlex(direction: Axis.vertical); final RenderFlex table = new RenderFlex(direction: Axis.vertical);
void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) { void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) {
TextStyle style = const TextStyle(color: const Color(0xFF000000)); TextStyle style = const TextStyle(color: const Color(0xFF000000));
RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$crossAxisAlignment')); final RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$crossAxisAlignment'));
table.add(new RenderPadding(child: paragraph, padding: const 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); final RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = const TextStyle(fontSize: 15.0, color: const Color(0xFF000000)); style = const TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox( row.add(new RenderDecoratedBox(
decoration: const BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)), decoration: const BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
...@@ -27,7 +27,7 @@ void main() { ...@@ -27,7 +27,7 @@ void main() {
decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)), decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo')) child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo'))
)); ));
RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic); final RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = const TextStyle(fontSize: 25.0, color: const Color(0xFF000000)); style = const TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
subrow.add(new RenderDecoratedBox( subrow.add(new RenderDecoratedBox(
decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)), decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
...@@ -48,9 +48,9 @@ void main() { ...@@ -48,9 +48,9 @@ void main() {
void addJustificationRow(MainAxisAlignment justify) { void addJustificationRow(MainAxisAlignment justify) {
const TextStyle style = const TextStyle(color: const Color(0xFF000000)); const TextStyle style = const TextStyle(color: const Color(0xFF000000));
RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$justify')); final RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$justify'));
table.add(new RenderPadding(child: paragraph, padding: const 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); final RenderFlex row = new RenderFlex(direction: Axis.horizontal);
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.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(0xFFCCFFCC), desiredSize: const Size(64.0, 60.0)));
row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0))); row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0)));
...@@ -66,7 +66,7 @@ void main() { ...@@ -66,7 +66,7 @@ void main() {
addJustificationRow(MainAxisAlignment.spaceBetween); addJustificationRow(MainAxisAlignment.spaceBetween);
addJustificationRow(MainAxisAlignment.spaceAround); addJustificationRow(MainAxisAlignment.spaceAround);
RenderDecoratedBox root = new RenderDecoratedBox( final RenderDecoratedBox root = new RenderDecoratedBox(
decoration: const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)), decoration: const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)) child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0))
); );
......
...@@ -19,12 +19,12 @@ class NonStopVSync implements TickerProvider { ...@@ -19,12 +19,12 @@ class NonStopVSync implements TickerProvider {
void main() { void main() {
// We first create a render object that represents a green box. // We first create a render object that represents a green box.
RenderBox green = new RenderDecoratedBox( final RenderBox green = new RenderDecoratedBox(
decoration: const BoxDecoration(backgroundColor: const Color(0xFF00FF00)) decoration: const BoxDecoration(backgroundColor: const Color(0xFF00FF00))
); );
// Second, we wrap that green box in a render object that forces the green box // Second, we wrap that green box in a render object that forces the green box
// to have a specific size. // to have a specific size.
RenderBox square = new RenderConstrainedBox( final RenderBox square = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0), additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0),
child: green child: green
); );
...@@ -32,13 +32,13 @@ void main() { ...@@ -32,13 +32,13 @@ void main() {
// transform before painting its child. Each frame of the animation, we'll // 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 // update the transform of this render object to cause the green square to
// spin. // spin.
RenderTransform spin = new RenderTransform( final RenderTransform spin = new RenderTransform(
transform: new Matrix4.identity(), transform: new Matrix4.identity(),
alignment: FractionalOffset.center, alignment: FractionalOffset.center,
child: square child: square
); );
// Finally, we center the spinning green square... // Finally, we center the spinning green square...
RenderBox root = new RenderPositionedBox( final RenderBox root = new RenderPositionedBox(
alignment: FractionalOffset.center, alignment: FractionalOffset.center,
child: spin child: spin
); );
...@@ -47,14 +47,14 @@ void main() { ...@@ -47,14 +47,14 @@ void main() {
// To make the square spin, we use an animation that repeats every 1800 // To make the square spin, we use an animation that repeats every 1800
// milliseconds. // milliseconds.
AnimationController animation = new AnimationController( final AnimationController animation = new AnimationController(
duration: const Duration(milliseconds: 1800), duration: const Duration(milliseconds: 1800),
vsync: const NonStopVSync(), vsync: const NonStopVSync(),
)..repeat(); )..repeat();
// The animation will produce a value between 0.0 and 1.0 each frame, but we // 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 // 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. // the range of the animation, we use a Tween.
Tween<double> tween = new Tween<double>(begin: 0.0, end: math.PI); final Tween<double> tween = new Tween<double>(begin: 0.0, end: math.PI);
// We add a listener to the animation, which will be called every time the // We add a listener to the animation, which will be called every time the
// animation ticks. // animation ticks.
animation.addListener(() { animation.addListener(() {
......
...@@ -167,13 +167,13 @@ abstract class RenderDecoratedSector extends RenderSector { ...@@ -167,13 +167,13 @@ abstract class RenderDecoratedSector extends RenderSector {
if (_decoration.backgroundColor != null) { if (_decoration.backgroundColor != null) {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
Paint paint = new Paint()..color = _decoration.backgroundColor; final Paint paint = new Paint()..color = _decoration.backgroundColor;
Path path = new Path(); final Path path = new Path();
double outerRadius = (parentData.radius + deltaRadius); final double outerRadius = (parentData.radius + deltaRadius);
Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); final Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius);
path.arcTo(outerBounds, parentData.theta, deltaTheta, true); path.arcTo(outerBounds, parentData.theta, deltaTheta, true);
double innerRadius = parentData.radius; final double innerRadius = parentData.radius;
Rect innerBounds = new Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius); final Rect innerBounds = new Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius);
path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false); path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false);
path.close(); path.close();
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
...@@ -248,19 +248,19 @@ class RenderSectorRing extends RenderSectorWithChildren { ...@@ -248,19 +248,19 @@ class RenderSectorRing extends RenderSectorWithChildren {
@override @override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
double outerDeltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius); final double outerDeltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
double innerDeltaRadius = outerDeltaRadius - padding * 2.0; final double innerDeltaRadius = outerDeltaRadius - padding * 2.0;
double childRadius = radius + padding; final double childRadius = radius + padding;
double paddingTheta = math.atan(padding / (radius + outerDeltaRadius)); final double paddingTheta = math.atan(padding / (radius + outerDeltaRadius));
double innerTheta = paddingTheta; // increments with each child double innerTheta = paddingTheta; // increments with each child
double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta); double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
SectorConstraints innerConstraints = new SectorConstraints( final SectorConstraints innerConstraints = new SectorConstraints(
maxDeltaRadius: innerDeltaRadius, maxDeltaRadius: innerDeltaRadius,
maxDeltaTheta: remainingDeltaTheta maxDeltaTheta: remainingDeltaTheta
); );
SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius); final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
innerTheta += childDimensions.deltaTheta; innerTheta += childDimensions.deltaTheta;
remainingDeltaTheta -= childDimensions.deltaTheta; remainingDeltaTheta -= childDimensions.deltaTheta;
final SectorChildListParentData childParentData = child.parentData; final SectorChildListParentData childParentData = child.parentData;
...@@ -280,14 +280,14 @@ class RenderSectorRing extends RenderSectorWithChildren { ...@@ -280,14 +280,14 @@ class RenderSectorRing extends RenderSectorWithChildren {
assert(this.parentData is SectorParentData); assert(this.parentData is SectorParentData);
deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius); deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
assert(deltaRadius < double.INFINITY); assert(deltaRadius < double.INFINITY);
double innerDeltaRadius = deltaRadius - padding * 2.0; final double innerDeltaRadius = deltaRadius - padding * 2.0;
double childRadius = this.parentData.radius + padding; final double childRadius = this.parentData.radius + padding;
double paddingTheta = math.atan(padding / (this.parentData.radius + deltaRadius)); final double paddingTheta = math.atan(padding / (this.parentData.radius + deltaRadius));
double innerTheta = paddingTheta; // increments with each child double innerTheta = paddingTheta; // increments with each child
double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta); double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
SectorConstraints innerConstraints = new SectorConstraints( final SectorConstraints innerConstraints = new SectorConstraints(
maxDeltaRadius: innerDeltaRadius, maxDeltaRadius: innerDeltaRadius,
maxDeltaTheta: remainingDeltaTheta maxDeltaTheta: remainingDeltaTheta
); );
...@@ -363,18 +363,18 @@ class RenderSectorSlice extends RenderSectorWithChildren { ...@@ -363,18 +363,18 @@ class RenderSectorSlice extends RenderSectorWithChildren {
@override @override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
assert(this.parentData is SectorParentData); assert(this.parentData is SectorParentData);
double paddingTheta = math.atan(padding / this.parentData.radius); final double paddingTheta = math.atan(padding / this.parentData.radius);
double outerDeltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta); final double outerDeltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
double innerDeltaTheta = outerDeltaTheta - paddingTheta * 2.0; final double innerDeltaTheta = outerDeltaTheta - paddingTheta * 2.0;
double childRadius = this.parentData.radius + padding; double childRadius = this.parentData.radius + padding;
double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
SectorConstraints innerConstraints = new SectorConstraints( final SectorConstraints innerConstraints = new SectorConstraints(
maxDeltaRadius: remainingDeltaRadius, maxDeltaRadius: remainingDeltaRadius,
maxDeltaTheta: innerDeltaTheta maxDeltaTheta: innerDeltaTheta
); );
SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius); final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
childRadius += childDimensions.deltaRadius; childRadius += childDimensions.deltaRadius;
remainingDeltaRadius -= childDimensions.deltaRadius; remainingDeltaRadius -= childDimensions.deltaRadius;
final SectorChildListParentData childParentData = child.parentData; final SectorChildListParentData childParentData = child.parentData;
...@@ -392,14 +392,14 @@ class RenderSectorSlice extends RenderSectorWithChildren { ...@@ -392,14 +392,14 @@ class RenderSectorSlice extends RenderSectorWithChildren {
assert(this.parentData is SectorParentData); assert(this.parentData is SectorParentData);
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta); deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
assert(deltaTheta <= kTwoPi); assert(deltaTheta <= kTwoPi);
double paddingTheta = math.atan(padding / this.parentData.radius); final double paddingTheta = math.atan(padding / this.parentData.radius);
double innerTheta = this.parentData.theta + paddingTheta; final double innerTheta = this.parentData.theta + paddingTheta;
double innerDeltaTheta = deltaTheta - paddingTheta * 2.0; final double innerDeltaTheta = deltaTheta - paddingTheta * 2.0;
double childRadius = this.parentData.radius + padding; double childRadius = this.parentData.radius + padding;
double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
SectorConstraints innerConstraints = new SectorConstraints( final SectorConstraints innerConstraints = new SectorConstraints(
maxDeltaRadius: remainingDeltaRadius, maxDeltaRadius: remainingDeltaRadius,
maxDeltaTheta: innerDeltaTheta maxDeltaTheta: innerDeltaTheta
); );
...@@ -489,9 +489,9 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil ...@@ -489,9 +489,9 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
assert(child.parentData is SectorParentData); assert(child.parentData is SectorParentData);
assert(width != null); assert(width != null);
assert(height != null); assert(height != null);
double maxChildDeltaRadius = math.min(width, height) / 2.0 - innerRadius; final double maxChildDeltaRadius = math.min(width, height) / 2.0 - innerRadius;
SectorDimensions childDimensions = child.getIntrinsicDimensions(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius); final SectorDimensions childDimensions = child.getIntrinsicDimensions(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius);
double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0; final double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0;
return constraints.constrain(new Size(dimension, dimension)); return constraints.constrain(new Size(dimension, dimension));
} }
...@@ -502,12 +502,12 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil ...@@ -502,12 +502,12 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
} else { } else {
assert(child is RenderSector); assert(child is RenderSector);
assert(constraints.maxWidth < double.INFINITY || constraints.maxHeight < double.INFINITY); assert(constraints.maxWidth < double.INFINITY || constraints.maxHeight < double.INFINITY);
double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius; final double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius;
assert(child.parentData is SectorParentData); assert(child.parentData is SectorParentData);
child.parentData.radius = innerRadius; child.parentData.radius = innerRadius;
child.parentData.theta = 0.0; child.parentData.theta = 0.0;
child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true); child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true);
double dimension = (innerRadius + child.deltaRadius) * 2.0; final double dimension = (innerRadius + child.deltaRadius) * 2.0;
size = constraints.constrain(new Size(dimension, dimension)); size = constraints.constrain(new Size(dimension, dimension));
} }
} }
...@@ -516,7 +516,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil ...@@ -516,7 +516,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
super.paint(context, offset); super.paint(context, offset);
if (child != null) { if (child != null) {
Rect bounds = offset & size; final Rect bounds = offset & size;
// we move the offset to the center of the circle for the RenderSectors // we move the offset to the center of the circle for the RenderSectors
context.paintChild(child, bounds.center.toOffset()); context.paintChild(child, bounds.center.toOffset());
} }
...@@ -532,8 +532,8 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil ...@@ -532,8 +532,8 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
x -= size.width/2.0; x -= size.width/2.0;
y -= size.height/2.0; y -= size.height/2.0;
// convert to radius/theta // convert to radius/theta
double radius = math.sqrt(x*x+y*y); final double radius = math.sqrt(x*x+y*y);
double theta = (math.atan2(x, -y) - math.PI/2.0) % kTwoPi; final double theta = (math.atan2(x, -y) - math.PI/2.0) % kTwoPi;
if (radius < innerRadius) if (radius < innerRadius)
return false; return false;
if (radius >= innerRadius + child.deltaRadius) if (radius >= innerRadius + child.deltaRadius)
......
...@@ -65,7 +65,7 @@ class RenderDots extends RenderBox { ...@@ -65,7 +65,7 @@ class RenderDots extends RenderBox {
@override @override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) { void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent) { if (event is PointerDownEvent) {
Color color = _kColors[event.pointer.remainder(_kColors.length)]; final Color color = _kColors[event.pointer.remainder(_kColors.length)];
_dots[event.pointer] = new Dot(color: color)..update(event); _dots[event.pointer] = new Dot(color: color)..update(event);
// We call markNeedsPaint to indicate that our painting commands have // We call markNeedsPaint to indicate that our painting commands have
// changed and that paint needs to be called before displaying a new frame // changed and that paint needs to be called before displaying a new frame
...@@ -101,7 +101,7 @@ class RenderDots extends RenderBox { ...@@ -101,7 +101,7 @@ class RenderDots extends RenderBox {
void main() { void main() {
// Create some styled text to tell the user to interact with the app. // Create some styled text to tell the user to interact with the app.
RenderParagraph paragraph = new RenderParagraph( final RenderParagraph paragraph = new RenderParagraph(
new TextSpan( new TextSpan(
style: new TextStyle(color: Colors.black87), style: new TextStyle(color: Colors.black87),
text: "Touch me!" text: "Touch me!"
...@@ -110,7 +110,7 @@ void main() { ...@@ -110,7 +110,7 @@ void main() {
// A stack is a render object that layers its children on top of each other. // 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 // The bottom later is our RenderDots object, and on top of that we show the
// text. // text.
RenderStack stack = new RenderStack( final RenderStack stack = new RenderStack(
children: <RenderBox>[ children: <RenderBox>[
new RenderDots(), new RenderDots(),
paragraph, paragraph,
......
...@@ -36,7 +36,7 @@ class Calculator { ...@@ -36,7 +36,7 @@ class Calculator {
// Run the computation associated with this Calculator. // Run the computation associated with this Calculator.
void run() { void run() {
int i = 0; int i = 0;
JsonDecoder decoder = new JsonDecoder( final JsonDecoder decoder = new JsonDecoder(
(dynamic key, dynamic value) { (dynamic key, dynamic value) {
if (key is int && i++ % _NOTIFY_INTERVAL == 0) if (key is int && i++ % _NOTIFY_INTERVAL == 0)
onProgressListener(i.toDouble(), _NUM_ITEMS.toDouble()); onProgressListener(i.toDouble(), _NUM_ITEMS.toDouble());
...@@ -44,8 +44,8 @@ class Calculator { ...@@ -44,8 +44,8 @@ class Calculator {
} }
); );
try { try {
List<dynamic> result = decoder.convert(_data); final List<dynamic> result = decoder.convert(_data);
int n = result.length; final int n = result.length;
onResultListener("Decoded $n results"); onResultListener("Decoded $n results");
} catch (e, stack) { } catch (e, stack) {
print("Invalid JSON file: $e"); print("Invalid JSON file: $e");
...@@ -54,7 +54,7 @@ class Calculator { ...@@ -54,7 +54,7 @@ class Calculator {
} }
static String _replicateJson(String data, int count) { static String _replicateJson(String data, int count) {
StringBuffer buffer = new StringBuffer()..write("["); final StringBuffer buffer = new StringBuffer()..write("[");
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
buffer.write(data); buffer.write(data);
if (i < count - 1) if (i < count - 1)
...@@ -178,8 +178,8 @@ class CalculationManager { ...@@ -178,8 +178,8 @@ class CalculationManager {
// Static and global variables are initialized anew in the spawned isolate, // Static and global variables are initialized anew in the spawned isolate,
// in a separate memory space. // in a separate memory space.
static void _calculate(CalculationMessage message) { static void _calculate(CalculationMessage message) {
SendPort sender = message.sendPort; final SendPort sender = message.sendPort;
Calculator calculator = new Calculator( final Calculator calculator = new Calculator(
onProgressListener: (double completed, double total) { onProgressListener: (double completed, double total) {
sender.send(<double>[ completed, total ]); sender.send(<double>[ completed, total ]);
}, },
......
...@@ -30,7 +30,7 @@ class RenderDots extends RenderConstrainedBox { ...@@ -30,7 +30,7 @@ class RenderDots extends RenderConstrainedBox {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF)); canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
Paint paint = new Paint()..color = const Color(0xFF00FF00); final Paint paint = new Paint()..color = const Color(0xFF00FF00);
for (Point point in _dots.values) for (Point point in _dots.values)
canvas.drawCircle(point, 50.0, paint); canvas.drawCircle(point, 50.0, paint);
......
...@@ -27,13 +27,13 @@ class _GesturePainter extends CustomPainter { ...@@ -27,13 +27,13 @@ class _GesturePainter extends CustomPainter {
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint(); final Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint();
double radius = size.width / 2.0 * zoom; final double radius = size.width / 2.0 * zoom;
Gradient gradient = new RadialGradient( final Gradient gradient = new RadialGradient(
colors: forward ? <Color>[swatch[50], swatch[900]] colors: forward ? <Color>[swatch[50], swatch[900]]
: <Color>[swatch[900], swatch[50]] : <Color>[swatch[900], swatch[50]]
); );
Paint paint = new Paint() final Paint paint = new Paint()
..shader = gradient.createShader(new Rect.fromLTWH( ..shader = gradient.createShader(new Rect.fromLTWH(
center.x - radius, center.x - radius,
center.y - radius, center.y - radius,
...@@ -92,7 +92,7 @@ class _GestureDemoState extends State<GestureDemo> { ...@@ -92,7 +92,7 @@ class _GestureDemoState extends State<GestureDemo> {
_zoom = (_previousZoom * details.scale); _zoom = (_previousZoom * details.scale);
// Ensure that item under the focal point stays in the same place despite zooming // Ensure that item under the focal point stays in the same place despite zooming
Offset normalizedOffset = (_startingFocalPoint.toOffset() - _previousOffset) / _previousZoom; final Offset normalizedOffset = (_startingFocalPoint.toOffset() - _previousOffset) / _previousZoom;
_offset = details.focalPoint.toOffset() - normalizedOffset * _zoom; _offset = details.focalPoint.toOffset() - normalizedOffset * _zoom;
}); });
} }
......
...@@ -90,7 +90,7 @@ class AdaptiveContainer extends StatelessWidget { ...@@ -90,7 +90,7 @@ class AdaptiveContainer extends StatelessWidget {
} }
List<String> _initNames() { List<String> _initNames() {
List<String> names = <String>[]; final List<String> names = <String>[];
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
names.add('Item $i'); names.add('Item $i');
return names; return names;
......
...@@ -54,13 +54,13 @@ class SectorAppState extends State<SectorApp> { ...@@ -54,13 +54,13 @@ class SectorAppState extends State<SectorApp> {
int index = 0; int index = 0;
while (index < actualSectorSizes.length && index < wantedSectorSizes.length && actualSectorSizes[index] == wantedSectorSizes[index]) while (index < actualSectorSizes.length && index < wantedSectorSizes.length && actualSectorSizes[index] == wantedSectorSizes[index])
index += 1; index += 1;
RenderSectorRing ring = sectors.child; final RenderSectorRing ring = sectors.child;
while (index < actualSectorSizes.length) { while (index < actualSectorSizes.length) {
ring.remove(ring.lastChild); ring.remove(ring.lastChild);
actualSectorSizes.removeLast(); actualSectorSizes.removeLast();
} }
while (index < wantedSectorSizes.length) { while (index < wantedSectorSizes.length) {
Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); final Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080);
ring.add(new RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index])); ring.add(new RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index]));
actualSectorSizes.add(wantedSectorSizes[index]); actualSectorSizes.add(wantedSectorSizes[index]);
index += 1; index += 1;
...@@ -68,7 +68,7 @@ class SectorAppState extends State<SectorApp> { ...@@ -68,7 +68,7 @@ class SectorAppState extends State<SectorApp> {
} }
static RenderBox initSector(Color color) { static RenderBox initSector(Color color) {
RenderSectorRing ring = new RenderSectorRing(padding: 1.0); 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(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)); ring.add(new RenderSolidColor(color, desiredDeltaTheta: kTwoPi * 0.2));
......
...@@ -9,9 +9,9 @@ import '../rendering/src/solid_color_box.dart'; ...@@ -9,9 +9,9 @@ import '../rendering/src/solid_color_box.dart';
// Solid colour, RenderObject version // Solid colour, RenderObject version
void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex: 0 }) { void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex: 0 }) {
RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor); final RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
parent.add(child); parent.add(child);
FlexParentData childParentData = child.parentData; final FlexParentData childParentData = child.parentData;
childParentData.flex = flex; childParentData.flex = flex;
} }
...@@ -80,7 +80,7 @@ RenderTransform transformBox; ...@@ -80,7 +80,7 @@ RenderTransform transformBox;
void rotate(Duration timeStamp) { void rotate(Duration timeStamp) {
if (timeBase == null) if (timeBase == null)
timeBase = timeStamp; timeBase = timeStamp;
double delta = (timeStamp - timeBase).inMicroseconds.toDouble() / Duration.MICROSECONDS_PER_SECOND; // radians final double delta = (timeStamp - timeBase).inMicroseconds.toDouble() / Duration.MICROSECONDS_PER_SECOND; // radians
transformBox.setIdentity(); transformBox.setIdentity();
transformBox.rotateZ(delta); transformBox.rotateZ(delta);
...@@ -89,17 +89,17 @@ void rotate(Duration timeStamp) { ...@@ -89,17 +89,17 @@ void rotate(Duration timeStamp) {
} }
void main() { void main() {
WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized(); final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
RenderProxyBox proxy = new RenderProxyBox(); final RenderProxyBox proxy = new RenderProxyBox();
attachWidgetTreeToRenderTree(proxy); attachWidgetTreeToRenderTree(proxy);
RenderFlex flexRoot = new RenderFlex(direction: Axis.vertical); final RenderFlex flexRoot = new RenderFlex(direction: Axis.vertical);
addFlexChildSolidColor(flexRoot, const Color(0xFFFF00FF), flex: 1); addFlexChildSolidColor(flexRoot, const Color(0xFFFF00FF), flex: 1);
flexRoot.add(proxy); flexRoot.add(proxy);
addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1); addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1);
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: FractionalOffset.center); transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: FractionalOffset.center);
RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox); final RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox);
binding.renderView.child = root; binding.renderView.child = root;
binding.addPersistentFrameCallback(rotate); binding.addPersistentFrameCallback(rotate);
......
...@@ -33,7 +33,7 @@ final TextStyle _kUnderline = const TextStyle( ...@@ -33,7 +33,7 @@ final TextStyle _kUnderline = const TextStyle(
); );
Widget toStyledText(String name, String text) { Widget toStyledText(String name, String text) {
TextStyle lineStyle = (name == "Dave") ? _kDaveStyle : _kHalStyle; final TextStyle lineStyle = (name == "Dave") ? _kDaveStyle : _kHalStyle;
return new RichText( return new RichText(
key: new Key(text), key: new Key(text),
text: new TextSpan( text: new TextSpan(
...@@ -94,11 +94,11 @@ class _StyledTextDemoState extends State<StyledTextDemo> { ...@@ -94,11 +94,11 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> lines = _kNameLines final List<Widget> lines = _kNameLines
.map<Widget>((List<String> nameAndText) => _toText(nameAndText[0], nameAndText[1])) .map<Widget>((List<String> nameAndText) => _toText(nameAndText[0], nameAndText[1]))
.toList(); .toList();
List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
for (Widget line in lines) { for (Widget line in lines) {
children.add(line); children.add(line);
if (line != lines.last) if (line != lines.last)
......
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