//platform: Android
//author: 'mulegame'
import 'package:flutter/material.dart';
class TabNavigator extends StatefulWidget {
@override
State<StatefulWidget> createState() => _TabNavigator();
}
// abstract class State<T extends StatefulWidget> with Diagnosticable{...}
class _TabNavigator extends State<TabNavigator> {
@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
}
重点1:
@override
State<StatefulWidget> createState() => _TabNavigator();
抛砖引玉: 为什么在TabNavigator中必须要重写(@override)State中的createState()?
查看State抽象类源码时发现:
abstract class State<T extends StatefulWidget> with Diagnosticable {
/// The current configuration.
///
/// A [State] object's configuration is the corresponding [StatefulWidget]
/// instance. This property is initialized by the framework before calling
/// [initState]. If the parent updates this location in the tree to a new
/// widget with the same [runtimeType] and [Widget.key] as the current
/// configuration, the framework will update this property to refer to the new
/// widget and then call [didUpdateWidget], passing the old configuration as
/// an argument.
T get widget => _widget!;
T? _widget;
/// The current stage in the lifecycle for this state object.
///
/// This field is used by the framework when asserts are enabled to verify
/// that [State] objects move through their l

最低0.47元/天 解锁文章
7095





