Rename ComponentState and use initState().
ComponentState becomes State, for brevity. Instead of overriding its constructor, override initState(). This makes writing States much simpler.
This commit is contained in:
@@ -10,12 +10,10 @@ class BigSwitch extends StatefulComponent {
|
||||
|
||||
final double scale;
|
||||
|
||||
BigSwitchState createState() => new BigSwitchState(this);
|
||||
BigSwitchState createState() => new BigSwitchState();
|
||||
}
|
||||
|
||||
class BigSwitchState extends ComponentState<BigSwitch> {
|
||||
BigSwitchState(BigSwitch config) : super(config);
|
||||
|
||||
class BigSwitchState extends State<BigSwitch> {
|
||||
bool _value = false;
|
||||
|
||||
void _handleOnChanged(bool value) {
|
||||
|
||||
@@ -8,11 +8,12 @@ import 'package:sky/material.dart';
|
||||
void main() => runApp(new DatePickerDemo());
|
||||
|
||||
class DatePickerDemo extends StatefulComponent {
|
||||
DatePickerDemoState createState() => new DatePickerDemoState(this);
|
||||
DatePickerDemoState createState() => new DatePickerDemoState();
|
||||
}
|
||||
|
||||
class DatePickerDemoState extends ComponentState<DatePickerDemo> {
|
||||
DatePickerDemoState(DatePickerDemo config) : super(config) {
|
||||
class DatePickerDemoState extends State<DatePickerDemo> {
|
||||
void initState(BuildContext context) {
|
||||
super.initState(context);
|
||||
DateTime now = new DateTime.now();
|
||||
_dateTime = new DateTime(now.year, now.month, now.day);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,10 @@ class DragData {
|
||||
}
|
||||
|
||||
class ExampleDragTarget extends StatefulComponent {
|
||||
ExampleDragTargetState createState() => new ExampleDragTargetState(this);
|
||||
ExampleDragTargetState createState() => new ExampleDragTargetState();
|
||||
}
|
||||
|
||||
class ExampleDragTargetState extends ComponentState<ExampleDragTarget> {
|
||||
ExampleDragTargetState(ExampleDragTarget config) : super(config);
|
||||
|
||||
class ExampleDragTargetState extends State<ExampleDragTarget> {
|
||||
String _text = 'ready';
|
||||
|
||||
void _handleAccept(DragData data) {
|
||||
@@ -71,9 +69,7 @@ class DragAndDropApp extends StatefulComponent {
|
||||
DragAndDropAppState createState() => new DragAndDropAppState(this);
|
||||
}
|
||||
|
||||
class DragAndDropAppState extends ComponentState<DragAndDropApp> {
|
||||
DragAndDropAppState(DragAndDropApp config) : super(config);
|
||||
|
||||
class DragAndDropAppState extends State<DragAndDropApp> {
|
||||
DragController _dragController;
|
||||
Offset _displacement = Offset.zero;
|
||||
|
||||
|
||||
@@ -61,12 +61,10 @@ List<Route> routes = [
|
||||
];
|
||||
|
||||
class NavigationExampleApp extends StatefulComponent {
|
||||
NavigationExampleAppState createState() => new NavigationExampleAppState(this);
|
||||
NavigationExampleAppState createState() => new NavigationExampleAppState();
|
||||
}
|
||||
|
||||
class NavigationExampleAppState extends ComponentState<NavigationExampleApp> {
|
||||
NavigationExampleAppState(NavigationExampleApp config) : super(config);
|
||||
|
||||
class NavigationExampleAppState extends State<NavigationExampleApp> {
|
||||
NavigatorHistory _history = new NavigatorHistory(routes);
|
||||
|
||||
void onBack() {
|
||||
|
||||
@@ -20,8 +20,9 @@ class PageableListApp extends StatefulComponent {
|
||||
PageableListAppState createState() => new PageableListAppState(this);
|
||||
}
|
||||
|
||||
class PageableListAppState extends ComponentState<PageableListApp> {
|
||||
PageableListAppState(PageableListApp config) : super(config) {
|
||||
class PageableListAppState extends State<PageableListApp> {
|
||||
void initState(BuildContext context) {
|
||||
super.initState(context);
|
||||
List<Size> cardSizes = [
|
||||
[100.0, 300.0], [300.0, 100.0], [200.0, 400.0], [400.0, 400.0], [300.0, 400.0]
|
||||
]
|
||||
|
||||
@@ -10,8 +10,9 @@ class ProgressIndicatorApp extends StatefulComponent {
|
||||
ProgressIndicatorAppState createState() => new ProgressIndicatorAppState(this);
|
||||
}
|
||||
|
||||
class ProgressIndicatorAppState extends ComponentState<ProgressIndicatorApp> {
|
||||
ProgressIndicatorAppState(ProgressIndicatorApp config) : super(config) {
|
||||
class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
|
||||
void initState(BuildContext context) {
|
||||
super.initState(context);
|
||||
valueAnimation = new ValueAnimation<double>()
|
||||
..duration = const Duration(milliseconds: 1500)
|
||||
..variable = new AnimatedValue<double>(
|
||||
|
||||
@@ -10,8 +10,9 @@ class ScaleApp extends StatefulComponent {
|
||||
ScaleAppState createState() => new ScaleAppState(this);
|
||||
}
|
||||
|
||||
class ScaleAppState extends ComponentState<ScaleApp> {
|
||||
ScaleAppState(ScaleApp config) : super(config) {
|
||||
class ScaleAppState extends State<ScaleApp> {
|
||||
void initState(BuildContext context) {
|
||||
super.initState(context);
|
||||
_offset = Offset.zero;
|
||||
_zoom = 1.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user