寻找一种更好的方法来解决如何从应用程序抽屉导航到下一页,我在其他文件中制作了一个有状态的小部件并在 main.dart 中导入,而不是
Navigate.pop(context);
我用什么?
我努力了
Navigator.of(context).push(
MaterialPageRoute<Null>(builder: (BuildContext context) {
return new HomePage();
它在前一页上加载页面并使事情变得滞后。
下面是代码。
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text('some text')),
drawer: Drawer(
// Add a ListView to the drawer. This ensures the user can scroll
// through the options in the drawer if there isn't enough vertical
// space to fit everything.
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(image: AssetImage("assets/gold.jpg"),fit: BoxFit.cover)
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer // how do i close the drawer after click?
Navigator.pop(context);
},
),
],
),
),
);
我希望当我单击应用程序抽屉链接时,它会将我带到一个新页面并关闭应用程序抽屉本身