【发布时间】:2020-03-26 18:58:50
【问题描述】:
使用默认的 Material Drawer 导航到 Flutter 页面的最佳原因是什么。 我仍在学习如何使用 Flutter。
在 Android 中,我们曾经导航到片段页面,但在 Flutter 中这是如何工作的?
我只是想了解如何在不使用 bloc 的情况下导航到抽屉项目。
class MdDrawer extends StatelessWidget {
final String title;
MdDrawer({Key key, this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Text('MyPage'),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: const Text(_AccountName),
accountEmail: const Text(_AccountEmail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.brown,
child: Text(_AccountAbbr),
),
),
ListTile(
leading: Icon(Icons.lightbulb_outline),
title: Text('Notes'),
onTap: () => _alertOnListTileTap(context),
),
Divider(),
...
],
),
),
);
}
_alertOnListTileTap(BuildContext context) {
Navigator.of(context).pop();
showDialog(
context: context,
child: AlertDialog(
title: const Text('Not Implemented'),
actions: <Widget>[
FlatButton(
child: const Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
);
}
}
【问题讨论】:
-
你试过
Navigator.push(context, MaterialPageRoute(builder: (context) => ExampleWidget()));吗? -
感谢您的提示 - 我会仔细看看
标签: android iphone flutter dart