【发布时间】:2019-03-13 19:01:21
【问题描述】:
我知道我可以在 Flutter 的 AppBar 的操作中使用 IconButton。但我希望用户看到的不是图标,而是“保存”或“返回”或“取消”字样,然后在 AppBar 中单击它们。我怎样才能做到这一点?这是我显示 AppBar 的代码的一部分。而不是保存图标,我想使用“保存”
return Scaffold(
appBar: AppBar(
leading: IconButton(icon: Icon(Icons.arrow_back),
tooltip: "Cancel and Return to List",
onPressed: () {
Navigator.pop(context, true);
},
),
automaticallyImplyLeading: false,
title: Text(title),
actions: <Widget>[
IconButton(
icon: Icon(Icons.save),
tooltip: "Save Todo and Retrun to List",
onPressed: () {
save();
},
)
],
),//AppBar
【问题讨论】:
-
你可以使用 FlatButton.icon(onPressed: (){save();}, icon: Icon(Icons.save), label: 'Save');而不是 Iconbutton。
-
非常感谢!我实际上需要一个平面按钮。
-
但它对arrow_back不起作用
-
确切地说:在前导部分没有足够的空间来放置单词“取消”而不是箭头
-
对于那些想要图标而不是文本的人,请参阅How to add icon to AppBar in Flutter