[英]Error thrown on navigator pop until : "!_debugLocked is not true
每當我當時運行應用程序時,主屏幕最多只顯示 5 秒,並且沒有點擊,我導航到另一個頁面。 其中第二頁是產品詳細信息頁面,在第一頁上,產品按類別顯示。
itemBuilder: (context, index) => ItemCard(
product: products[index],
press: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailsScreen(
product: products[index],
),
)),
)),
),
),
],
);
}
}```
The following assertion was thrown while handling a gesture:
Assertion failed: file:///C:/src/flutter/flutter/packages/flutter/lib/src/widgets/navigator.dart:4842:12
!_debugLocked
is not true
您必須確保在導航之前已構建小部件樹,您可以通過像這樣扭曲 function 來做到這一點
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.push(context, MaterialPageRoute(builder: (_) =>
MyPage()));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.