有一个 Cupertino 导航来显示应用程序栏,但需要有结束抽屉
Has a Cupertino Navigation to show the app bar but need have end drawer
我正在尝试使用 endDrawer 添加 CupertinoNavigationBar
,我尝试在尾部添加手势检测器,但没有用,显示如下:
The following assertion was thrown while handling a gesture:
flutter: `Scaffold.of()` called with a context that does not contain a Scaffold.
flutter: No Scaffold ancestor could be found starting from the context that was passed to `Scaffold.of()`. This
flutter: usually happens when the context provided is from the same StatefulWidget as that whose build
我已经尝试将密钥添加到脚手架并尝试使用密钥打开,我也尝试在 appbar 中使用脚手架上下文
应用栏:
Scaffold(
appBar: CupertinoNavigationBar(
transitionBetweenRoutes: true,
trailing: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openEndDrawer();
},),
actionsForegroundColor: Colors.white,
middle: Text('Lejour', style: TextStyle(color: Colors.white)),
backgroundColor: Theme.of(context).primaryColor),
endDrawer: DrawerMenu() // my own class,
body: // ...body
我希望 CupertinoNavigationBar 的尾随图标用
打开 endDrawer
Scaffold.of(context).openEndDrawer();
这是您尝试使用 Scaffold.of(context)
时的常见问题。您应该阅读错误日志。
No Scaffold ancestor could be found starting from the context that was
passed to Scaffold.of()
要解决您的问题,请使用 Builder
小部件生成新的上下文。
trailing: Builder(
builder: (context) {
return IconButton(
icon: Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
);
},
),
我正在尝试使用 endDrawer 添加 CupertinoNavigationBar
,我尝试在尾部添加手势检测器,但没有用,显示如下:
The following assertion was thrown while handling a gesture:
flutter: `Scaffold.of()` called with a context that does not contain a Scaffold.
flutter: No Scaffold ancestor could be found starting from the context that was passed to `Scaffold.of()`. This
flutter: usually happens when the context provided is from the same StatefulWidget as that whose build
我已经尝试将密钥添加到脚手架并尝试使用密钥打开,我也尝试在 appbar 中使用脚手架上下文
应用栏:
Scaffold(
appBar: CupertinoNavigationBar(
transitionBetweenRoutes: true,
trailing: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openEndDrawer();
},),
actionsForegroundColor: Colors.white,
middle: Text('Lejour', style: TextStyle(color: Colors.white)),
backgroundColor: Theme.of(context).primaryColor),
endDrawer: DrawerMenu() // my own class,
body: // ...body
我希望 CupertinoNavigationBar 的尾随图标用
打开 endDrawer
Scaffold.of(context).openEndDrawer();
这是您尝试使用 Scaffold.of(context)
时的常见问题。您应该阅读错误日志。
No Scaffold ancestor could be found starting from the context that was passed to
Scaffold.of()
要解决您的问题,请使用 Builder
小部件生成新的上下文。
trailing: Builder(
builder: (context) {
return IconButton(
icon: Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
);
},
),