我正在尝试使用StatefulWidget创建路由。
错误:
I/flutter (23141): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (23141): The following assertion was thrown building
I/flutter (23141): _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#3e9ee](dirty, state: _OverlayEntryState#7b90c):
I/flutter (23141): The builder for route "/" returned null.
I/flutter (23141): Route builders must never return null.
代码:
routes:<String,WidgetBuilder>{
"/":(_)=>new RouteHome(title: 'Flutter Demo Home Page'),
...
class RouteHome extends StatefulWidget {
RouteHome({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
查询:
问题: 如果更改了窗口小部件的基类,则路由的热重新加载失败(StatefulWidget&lt; - &gt; StatelessWidget)。
答案 0 :(得分:4)
热重新加载仅用于最小的UI更改。
<强>提供者:强> “这不是一个问题,使用热重新加载来进行UI中的微小更改。通常你需要 在创建新类时执行完全重启。“ - @aziza