我想創建如下圖所示的 PopUpMenuButton。
是否可以在按鈕內創建 PopUpMenuButton?因為我仍然不知道如何創建一個函式。我找到的教程是將選單放在應用欄上。這不相關。
在這里我附上我的代碼。
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
height: 26,
width: 26,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black, width: 1),
),
child: IconButton(
icon: const Icon(Icons.more_horiz),
padding: const EdgeInsets.all(5),
iconSize: 15,
onPressed: () {
PopupMenuButton( // <---- PopUpMenuButton
itemBuilder: (context) {},
);
},
),
),
],
),
uj5u.com熱心網友回復:
而不是你的IconButton
use PopupMenuButton
,像這樣:
child: PopupMenuButton(
offset: Offset(0, 40),
child: Icon(Icons.more_horiz_rounded),
itemBuilder: (_) => <PopupMenuItem<String>>[
PopupMenuItem<String>(
child: Row(
children: [Icon(Icons.update), Text('update')],
),
value: 'update'),
PopupMenuItem<String>(
child: Row(
children: [Icon(Icons.delete), Text('delete')],
),
value: 'delete'),
],
onSelected: (_) {},
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/535426.html
標籤:扑颤动布局颤振网
上一篇:沒有創建Firebase應用'[DEFAULT]'-呼叫Firebase.initializeApp()-Flutter