1
A
回答
0
1
如果你想显示在您的应用程序的权利酒吧/菜单或Drawer
,无论是具有永久视图或临时之一。我可以通过构建我自己的自定义小部件(从Allign
,Container
和Column
小部件以及使用setState
来显示或隐藏基于用户交互的菜单栏来实现此目的),请参阅此简单示例。
我的自定义菜单窗口小部件看起来如下:
class RightNavigationBar extends StatefulWidget {
@override
_RightNavigationBarState createState() => new _RightNavigationBarState();
}
class _RightNavigationBarState extends State<RightNavigationBar> {
@override
Widget build(BuildContext context) {
return new Align(
alignment: FractionalOffset.centerRight,
child: new Container(
child: new Column(
children: <Widget>[
new Icon(Icons.navigate_next),
new Icon(Icons.close),
new Text ("More items..")
],
),
color: Colors.blueGrey,
height: 700.0,
width: 200.0,
),
);
}
}
然后,当用户按下菜单icon
,我的自定义RightNavigationBar
小部件内setState
创建的对象:
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _myRightBar = null;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
actions: [new IconButton(
icon: new Icon (Icons.menu), onPressed: _showRightBar)
],
title: new Text("Right Navigation Bar Example"),
),
body: _myRightBar
);
}
_showRightBar() {
setState(() {
_myRightBar == null
? _myRightBar = new RightNavigationBar()
: _myRightBar = null;
});
}
}
相关问题
- 1. 如何实现此处的导航栏?
- 2. jqgrid导航栏不能正确呈现
- 3. 如何正确修复导航栏?
- 4. 如何正确实现固定侧栏?
- 5. 引导导航栏工作不正确
- 6. 如何实现二级导航栏使用jQuery移动
- 7. 为什么引导拨动导航栏不显示正确
- 8. UINavigationController导航栏没有正确定位
- 9. bootstrap导航栏没有显示正确
- 10. 如何设置正确的导航栏色调颜色?
- 11. 如何实现浏览页面时稳定的导航栏?
- 12. Angular 4 Bootstrap alpha导航栏无法正确呈现
- 13. safari导航栏...如何重现它?
- 14. 实现动态内容的透明模糊导航栏
- 15. 如何获得正确的动画:从UINavigationController的导航栏中输入视图?
- 16. 如何让Bootstrap导航栏在Microsoft Edge中正确显示?
- 17. 如何正确加载导航栏和页面内容?
- 18. 如何在android中实现底部导航栏?
- 19. 如何使用bootstrap导航栏组件实现反应路由?
- 20. 导航栏动画
- 21. 导航栏滚动
- 22. 动画导航栏
- 23. IOS半透明导航栏,但坚实的导航栏按钮
- 24. xamarin导航 - 如何正常实现登录和masterdetailpage之间的导航
- 25. 确定当前导航栏
- 26. 确保导航栏全宽
- 27. Bootstrap导航栏移动视图没有正确合拢
- 28. 如何正确对齐twitter twitter bootstrap导航栏中的导航栏项目使用反应
- 29. React Native:如何使用NavigationExperimental正确实现React Native Drawer的导航?
- 30. bootstrap导航栏不出现