我正在尝试将文本添加到floatingActionButton
中,但是无法这样做。我如何将文本添加到它找不到任何方法。
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
// when clicked on floating action button prompt to create user
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) => CreateUser(),
),
);
},
),
);
}
最佳答案
您可以使用FloatingActionButton.extended
一次在FAB中显示文本和图标。
FloatingActionButton.extended(
onPressed: () {
// when clicked on floating action button prompt to create user
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) => CreateUser(),
),
);
},
label: Text('Label'),
icon: Icon(Icons.add),
),
关于flutter - 如何在我的floatActionButton中添加文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62067232/