Last active
April 5, 2018 01:26
-
-
Save scheglov/2d0de1834f8b27e97cfd84ce08eab83c to your computer and use it in GitHub Desktop.
Instrumented file https://gist.github.com/scheglov/4aed80727855aafd627cd4137dfeeea7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class MyWidget extends StatelessWidget { | |
final String firstText; | |
MyWidget(this.firstText); | |
factory MyWidget.forDesignTime() { | |
return _registerWidgetInstance(0, new MyWidget('AA')); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return _registerWidgetInstance(1, new Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
_registerWidgetInstance(2, buildText(firstText)), | |
_registerWidgetInstance(3, buildText('BBBB')), | |
_registerWidgetInstance(4, buildText('CCCCCC')), | |
_registerWidgetInstance(5, buildText('DDDDDDDD')), | |
], | |
)); | |
} | |
Text buildText(String text) { | |
return _registerWidgetInstance(6, new Text(text, style: const TextStyle(fontSize: 24.0))); | |
} | |
} | |
final flutterDesignerWidgets = <int, Widget>{}; | |
T _registerWidgetInstance<T extends Widget>(int id, T widget) { | |
flutterDesignerWidgets[id] = widget; | |
return widget; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment