Commit a309cea1 authored by Hixie's avatar Hixie

Resurrect spinning_mixed.

It had bit-rotted. Also improve our error reporting for missing Material.
parent b5470df8
...@@ -40,27 +40,28 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { ...@@ -40,27 +40,28 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new Rectangle(const Color(0xFF00FFFF)), new Rectangle(const Color(0xFF00FFFF)),
new Container( new Material(
padding: new EdgeDims.all(10.0), child: new Container(
margin: new EdgeDims.all(10.0), padding: new EdgeDims.all(10.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), margin: new EdgeDims.all(10.0),
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new RaisedButton( new RaisedButton(
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new NetworkImage(src: "http://flutter.io/favicon.ico"), new NetworkImage(src: "http://flutter.io/favicon.ico"),
new Text('PRESS ME'), new Text('PRESS ME'),
] ]
),
onPressed: () {
value = value == null ? 0.1 : (value + 0.1) % 1.0;
attachWidgetTreeToRenderTree(container);
}
), ),
onPressed: () { new CircularProgressIndicator(value: value),
value = value == null ? 0.1 : (value + 0.1) % 1.0; ],
attachWidgetTreeToRenderTree(container); justifyContent: FlexJustifyContent.spaceAround
} )
),
new CircularProgressIndicator(value: value),
],
justifyContent: FlexJustifyContent.spaceAround
) )
), ),
new Rectangle(const Color(0xFFFFFF00)), new Rectangle(const Color(0xFFFFFF00)),
...@@ -86,6 +87,7 @@ void rotate(Duration timeStamp) { ...@@ -86,6 +87,7 @@ void rotate(Duration timeStamp) {
} }
void main() { void main() {
WidgetFlutterBinding.ensureInitialized();
RenderProxyBox proxy = new RenderProxyBox(); RenderProxyBox proxy = new RenderProxyBox();
attachWidgetTreeToRenderTree(proxy); attachWidgetTreeToRenderTree(proxy);
...@@ -97,7 +99,6 @@ void main() { ...@@ -97,7 +99,6 @@ void main() {
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity()); transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity());
RenderPadding root = new RenderPadding(padding: new EdgeDims.all(80.0), child: transformBox); RenderPadding root = new RenderPadding(padding: new EdgeDims.all(80.0), child: transformBox);
WidgetFlutterBinding.ensureInitialized() WidgetFlutterBinding.instance.renderView.child = root;
..renderView.child = root WidgetFlutterBinding.instance.addPersistentFrameCallback(rotate);
..addPersistentFrameCallback(rotate);
} }
...@@ -8,11 +8,14 @@ import 'material.dart'; ...@@ -8,11 +8,14 @@ import 'material.dart';
bool debugCheckHasMaterial(BuildContext context) { bool debugCheckHasMaterial(BuildContext context) {
assert(() { assert(() {
if (context.widget is Material || context.ancestorWidgetOfExactType(Material) != null) if (context.widget is! Material && context.ancestorWidgetOfExactType(Material) == null) {
return true; Element element = context;
Element element = context; throw new WidgetError(
debugPrint('${context.widget} needs to be placed inside a Material widget. Ownership chain:\n${element.debugGetOwnershipChain(10)}'); 'Missing Material widget.',
return false; '${context.widget} needs to be placed inside a Material widget. Ownership chain:\n${element.debugGetOwnershipChain(10)}'
);
}
return true;
}); });
return true; return true;
} }
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