1
A
回答
3
顫振的popup menu有很多內部常量,它要求彈出的軸是垂直的。如果要更改軸並完全控制佈局和大小,您可以複製該文件並開始編輯它。
如果您對佈局不太挑剔,您可以通過將小部件作爲單個彈出式菜單項嵌入來僞裝它。下面是一些代碼證明方法:
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
home: new MyHomePage(),
);
}
}
/// An arbitrary widget that lives in a popup menu
class PopupMenuWidget<T> extends PopupMenuEntry<T> {
const PopupMenuWidget({ Key key, this.height, this.child }) : super(key: key);
@override
final Widget child;
@override
final double height;
@override
bool get enabled => false;
@override
_PopupMenuWidgetState createState() => new _PopupMenuWidgetState();
}
class _PopupMenuWidgetState extends State<PopupMenuWidget> {
@override
Widget build(BuildContext context) => widget.child;
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
actions: <Widget>[
new PopupMenuButton<String>(
onSelected: (String value) {
print("You selected $value");
},
itemBuilder: (BuildContext context) {
return [
new PopupMenuWidget(
height: 40.0,
child: new Row(
children: [
new IconButton(
icon: new Icon(Icons.add),
onPressed:() => Navigator.pop(context, 'add')),
new IconButton(
icon: new Icon(Icons.remove),
onPressed:() => Navigator.pop(context, 'remove')),
],
),
),
];
}
),
],
),
);
}
}
相關問題
- 1. 水平對齊
- 2. 水平對齊
- 3. 水平對齊
- 4. 水平CSS對齊
- 5. XAML水平對齊
- 6. WPF:水平對齊
- 7. 水平對齊div
- 8. 水平對齊DIV
- 9. 水平對齊div
- 10. CSS - 水平對齊
- 11. 水平線對齊
- 12. UICollectionView水平對齊水平滾動
- 13. 將div的水平對齊
- 14. CSS,jQuery的水平對齊
- 15. pdftext的ItextSharp水平對齊
- 16. CSS中的水平對齊
- 17. 水平對齊的div
- 18. 水平對齊的ListViewItem
- 19. 垂直對齊和水平對齊
- 20. 對齊圖片 - 水平對齊
- 21. 波旁整齊水平對齊的div
- 22. 水平對齊浮動
- 23. 水平對齊兩個DIV
- 24. 水平對齊自舉井
- 25. 圖片庫水平對齊
- 26. css div水平對齊
- 27. CSS水平對齊問題
- 28. listbox水平對齊換行
- 29. 通過CSS水平對齊
- 30. Div並非水平對齊
我已經挖成的代碼,我一直在尋找有關最好的方法確認。謝謝@collin。 –