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. 置頂導航欄在顫動
- 3. 如何實現此處的導航欄?
- 4. jqgrid導航欄不能正確呈現
- 5. 如何正確修復導航欄?
- 6. 如何正確構建php導航欄
- 7. 如何在angularjs中實現導航欄
- 8. 如何實現此導航欄佈局?
- 9. 導航欄邏輯實現
- 10. 無法正確實現導航抽屜
- 11. 如何正確實現固定側欄?
- 12. 引導導航欄工作不正確
- 13. 引導導航欄不顯示正確
- 14. 如何實現二級導航欄使用jQuery移動
- 15. 如何像「水平滾動導航欄」一樣實現分頁?
- 16. 導航欄正在移動
- 17. 如何實現自動隱藏導航?
- 18. WordPress的導航欄呈現不正確的IE7
- 19. iOS 7導航欄呈現不正確的RGB
- 20. 爲什麼引導撥動導航欄不顯示正確
- 21. 導航欄顯示不正確
- 22. bootstrap導航欄沒有顯示正確
- 23. 導航欄不正確居中(HTML/CSS)
- 24. UINavigationController導航欄沒有正確定位
- 25. 導航欄未正確排列
- 26. 導航側欄顯示不正確
- 27. HTML導航欄鏈接不正確
- 28. 導航欄無法正確顯示
- 29. 如何設置正確的導航欄色調顏色?
- 30. 如何實現瀏覽頁面時穩定的導航欄?