我正在尝试将文本添加到我的,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(),
),
);
},
),
);
}
Run Code Online (Sandbox Code Playgroud)
您可以使用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),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1292 次 |
| 最近记录: |