我有一個簡單的測驗,在初始化 4000 毫秒后打開新頁面。但我有這個 UI 錯誤
following _TypeError was thrown building WithPages(dirty, dependencies: [MediaQuery], state: _WithPages#6c08e):
type 'Future<dynamic>' is not a subtype of type 'Widget'
這是我的代碼
@override
void initState() {
Future.delayed(const Duration(milliseconds: 4000), () {
load_first_launch_start();
});
super.initState();
}
load_first_launch_start() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
first_launch = prefs.getInt('first_launch')??0;
if(first_launch>=1){
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(
builder: (context) => DrawerPage(),
), (e) => false);
}else{
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WithPages(),
), //MaterialPageRoute
);
}
});
}
uj5u.com熱心網友回復:
錯誤說 WithPages() 不是小部件或不回傳小部件
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/489958.html
標籤:扑
上一篇:如何使用powershell將文本檔案作為列添加到現有csv?
下一篇:INDART-toList()方法不會將int的Iterable轉換為串列,但是當它在print()中應用時,它可以正常作業。為什么?
