Strong modeify the examples
This makes skyanalyzer also check the examples, and fixes everything it found there.
This commit is contained in:
@@ -7,34 +7,34 @@ import 'package:flutter/rendering.dart';
|
||||
import 'lib/solid_color_box.dart';
|
||||
|
||||
void main() {
|
||||
var table = new RenderFlex(direction: FlexDirection.vertical);
|
||||
RenderFlex table = new RenderFlex(direction: FlexDirection.vertical);
|
||||
|
||||
for(FlexAlignItems alignItems in FlexAlignItems.values) {
|
||||
for (FlexAlignItems alignItems in FlexAlignItems.values) {
|
||||
TextStyle style = const TextStyle(color: const Color(0xFF000000));
|
||||
RenderParagraph paragraph = new RenderParagraph(new StyledTextSpan(style, [new PlainTextSpan("${alignItems}")]));
|
||||
RenderParagraph paragraph = new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan("$alignItems")]));
|
||||
table.add(new RenderPadding(child: paragraph, padding: new EdgeDims.only(top: 20.0)));
|
||||
var row = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
|
||||
|
||||
RenderFlex row = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
|
||||
style = new TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
|
||||
row.add(new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
|
||||
child: new RenderParagraph(new StyledTextSpan(style, [new PlainTextSpan('foo foo foo')]))
|
||||
child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo')]))
|
||||
));
|
||||
style = new TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
|
||||
row.add(new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
|
||||
child: new RenderParagraph(new StyledTextSpan(style, [new PlainTextSpan('foo foo foo')]))
|
||||
child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo')]))
|
||||
));
|
||||
var subrow = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
|
||||
RenderFlex subrow = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
|
||||
style = new TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
|
||||
subrow.add(new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
|
||||
child: new RenderParagraph(new StyledTextSpan(style, [new PlainTextSpan('foo foo foo foo')]))
|
||||
child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo foo')]))
|
||||
));
|
||||
subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: new Size(30.0, 40.0)));
|
||||
row.add(subrow);
|
||||
table.add(row);
|
||||
row.parentData.flex = 1;
|
||||
final FlexParentData rowParentData = row.parentData;
|
||||
rowParentData.flex = 1;
|
||||
}
|
||||
|
||||
RenderDecoratedBox root = new RenderDecoratedBox(
|
||||
|
||||
@@ -12,7 +12,7 @@ RenderBox getBox(double lh) {
|
||||
new TextStyle(
|
||||
color: const Color(0xFF0000A0)
|
||||
),
|
||||
[
|
||||
<TextSpan>[
|
||||
new PlainTextSpan('test'),
|
||||
new StyledTextSpan(
|
||||
new TextStyle(
|
||||
@@ -20,7 +20,7 @@ RenderBox getBox(double lh) {
|
||||
fontSize: 50.0,
|
||||
height: lh
|
||||
),
|
||||
[new PlainTextSpan('مرحبا Hello')]
|
||||
<TextSpan>[new PlainTextSpan('مرحبا Hello')]
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -62,7 +62,7 @@ RenderBox getBox(double lh) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
RenderBox root = new RenderFlex(children: [
|
||||
RenderBox root = new RenderFlex(children: <RenderBox>[
|
||||
new RenderConstrainedBox(
|
||||
additionalConstraints: new BoxConstraints.tightFor(height: 50.0)
|
||||
),
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'dart:ui' as ui;
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
void main() {
|
||||
var root = new RenderFlex(
|
||||
children: [
|
||||
RenderFlex root = new RenderFlex(
|
||||
children: <RenderBox>[
|
||||
new RenderPadding(
|
||||
padding: new EdgeDims.all(10.0),
|
||||
child: new RenderConstrainedBox(
|
||||
|
||||
@@ -46,7 +46,8 @@ RenderBox buildFlexExample() {
|
||||
);
|
||||
|
||||
flexRoot.add(decoratedRow);
|
||||
decoratedRow.parentData.flex = 3;
|
||||
final FlexParentData decoratedRowParentData = decoratedRow.parentData;
|
||||
decoratedRowParentData.flex = 3;
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class RenderImageGrow extends RenderImage {
|
||||
|
||||
RenderImageGrow image;
|
||||
|
||||
Map<int, Touch> touches = new Map();
|
||||
final Map<int, Touch> touches = <int, Touch>{};
|
||||
void handleEvent(event) {
|
||||
if (event is ui.PointerEvent) {
|
||||
if (event.type == 'pointermove')
|
||||
@@ -64,8 +64,7 @@ void main() {
|
||||
image.image = dartLogo;
|
||||
});
|
||||
|
||||
var padding = new RenderPadding(padding: const EdgeDims.all(10.0), child: image);
|
||||
row.add(padding);
|
||||
row.add(new RenderPadding(padding: const EdgeDims.all(10.0), child: image));
|
||||
|
||||
RenderFlex column = new RenderFlex(direction: FlexDirection.vertical);
|
||||
|
||||
@@ -79,13 +78,14 @@ porchetta bacon kevin meatball meatloaf pig beef ribs chicken. Brisket ribeye
|
||||
andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
|
||||
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
|
||||
Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
|
||||
var text = new StyledTextSpan(
|
||||
new TextStyle(color: const Color(0xFF009900)),
|
||||
[new PlainTextSpan(meatyString)]);
|
||||
padding = new RenderPadding(
|
||||
padding: const EdgeDims.all(10.0),
|
||||
child: new RenderParagraph(text));
|
||||
column.add(padding);
|
||||
TextSpan text = new StyledTextSpan(
|
||||
new TextStyle(color: const Color(0xFF009900)),
|
||||
<TextSpan>[new PlainTextSpan(meatyString)]
|
||||
);
|
||||
column.add(new RenderPadding(
|
||||
padding: const EdgeDims.all(10.0),
|
||||
child: new RenderParagraph(text)
|
||||
));
|
||||
|
||||
// Bottom cell
|
||||
addFlexChildSolidColor(column, const Color(0xFF0081C6), flex: 2);
|
||||
|
||||
@@ -14,15 +14,16 @@ void main() {
|
||||
var table = new RenderFlex(direction: FlexDirection.vertical);
|
||||
|
||||
void addRow(FlexJustifyContent justify) {
|
||||
RenderParagraph paragraph = new RenderParagraph(new StyledTextSpan(style, [new PlainTextSpan("${justify}")]));
|
||||
RenderParagraph paragraph = new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan("$justify")]));
|
||||
table.add(new RenderPadding(child: paragraph, padding: new EdgeDims.only(top: 20.0)));
|
||||
var row = new RenderFlex(direction: FlexDirection.horizontal);
|
||||
RenderFlex row = new RenderFlex(direction: FlexDirection.horizontal);
|
||||
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: new Size(80.0, 60.0)));
|
||||
row.add(new RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: new Size(64.0, 60.0)));
|
||||
row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: new Size(160.0, 60.0)));
|
||||
row.justifyContent = justify;
|
||||
table.add(row);
|
||||
row.parentData.flex = 1;
|
||||
final FlexParentData rowParentData = row.parentData;
|
||||
rowParentData.flex = 1;
|
||||
}
|
||||
|
||||
addRow(FlexJustifyContent.start);
|
||||
|
||||
@@ -19,7 +19,7 @@ Color randomColor() {
|
||||
}
|
||||
|
||||
RenderBox buildGridExample() {
|
||||
List<RenderBox> children = new List.generate(30, (_) => new RenderSolidColorBox(randomColor()));
|
||||
List<RenderBox> children = new List<RenderBox>.generate(30, (_) => new RenderSolidColorBox(randomColor()));
|
||||
return new RenderGrid(children: children, maxChildExtent: 100.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,11 @@ void main() {
|
||||
child: flexRoot
|
||||
);
|
||||
|
||||
FlexParentData childParentData;
|
||||
|
||||
RenderObject child = new RenderSolidColorBox(const Color(0xFFFFFF00));
|
||||
flexRoot.add(child);
|
||||
FlexParentData childParentData = child.parentData;
|
||||
childParentData = child.parentData;
|
||||
childParentData.flex = 2;
|
||||
|
||||
// The internet is a beautiful place. https://baconipsum.com/
|
||||
@@ -26,9 +28,10 @@ andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
|
||||
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
|
||||
Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
|
||||
|
||||
var text = new StyledTextSpan(
|
||||
new TextStyle(color: const Color(0xFF009900)),
|
||||
[new PlainTextSpan(meatyString)]);
|
||||
StyledTextSpan text = new StyledTextSpan(
|
||||
new TextStyle(color: const Color(0xFF009900)),
|
||||
<TextSpan>[new PlainTextSpan(meatyString)]
|
||||
);
|
||||
child = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
|
||||
child: new RenderParagraph(text)
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new RadialGradient(
|
||||
center: Point.origin, radius: 500.0,
|
||||
colors: [Colors.yellow[500], Colors.blue[500]]),
|
||||
colors: <Color>[Colors.yellow[500], Colors.blue[500]]),
|
||||
boxShadow: shadows[3])
|
||||
);
|
||||
var paddedBox = new RenderPadding(
|
||||
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF))
|
||||
);
|
||||
|
||||
RenderAutoLayout root = new RenderAutoLayout(children: [c1, c2, c3, c4]);
|
||||
RenderAutoLayout root = new RenderAutoLayout(children: <RenderBox>[c1, c2, c3, c4]);
|
||||
|
||||
AutoLayoutParentData p1 = c1.parentData;
|
||||
AutoLayoutParentData p2 = c2.parentData;
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
// Material design colors. :p
|
||||
List<Color> kColors = [
|
||||
List<Color> kColors = <Color>[
|
||||
Colors.teal[500],
|
||||
Colors.amber[500],
|
||||
Colors.purple[500],
|
||||
@@ -34,9 +34,7 @@ class Dot {
|
||||
}
|
||||
|
||||
class RenderTouchDemo extends RenderBox {
|
||||
Map<int, Dot> dots = new Map();
|
||||
|
||||
RenderTouchDemo();
|
||||
final Map<int, Dot> dots = <int, Dot>{};
|
||||
|
||||
void handleEvent(InputEvent event, BoxHitTestEntry entry) {
|
||||
if (event is PointerInputEvent) {
|
||||
@@ -49,7 +47,7 @@ class RenderTouchDemo extends RenderBox {
|
||||
dots.remove(event.pointer);
|
||||
break;
|
||||
case 'pointercancel':
|
||||
dots = new Map();
|
||||
dots.clear();
|
||||
break;
|
||||
case 'pointermove':
|
||||
dots[event.pointer].update(event);
|
||||
@@ -74,14 +72,15 @@ class RenderTouchDemo extends RenderBox {
|
||||
}
|
||||
|
||||
void main() {
|
||||
var paragraph = new RenderParagraph(new PlainTextSpan("Touch me!"));
|
||||
var stack = new RenderStack(children: [
|
||||
RenderParagraph paragraph = new RenderParagraph(new PlainTextSpan("Touch me!"));
|
||||
RenderStack stack = new RenderStack(children: <RenderBox>[
|
||||
new RenderTouchDemo(),
|
||||
paragraph,
|
||||
]);
|
||||
// Prevent the RenderParagraph from filling the whole screen so
|
||||
// that it doesn't eat events.
|
||||
paragraph.parentData..top = 40.0
|
||||
..left = 20.0;
|
||||
final StackParentData paragraphParentData = paragraph.parentData;
|
||||
paragraphParentData..top = 40.0
|
||||
..left = 20.0;
|
||||
new FlutterBinding(root: stack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user