flutter - 如何在persistentFooterButtons中居中FloatingActionButton
问题描述
有人可以向我解释如何将 FloatingActionButton 居中在persistentFooterButtons 中。我在这里错过了一些东西。
List _footer() {
return <Widget>[
new ButtonBar(
children: <Widget>[
new Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new FloatingActionButton(
backgroundColor: Colors.redAccent,
onPressed: () => {},
),
],
),
)
],
)
];}
===
@override Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Question"),
),
body: _body(),
persistentFooterButtons: _footer(),
); }
解决方案
我发现一个简单的解决方案是将 FloatingActionButton 包装在与屏幕宽度相同的大小框中。
persistentFooterButtons: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
child: FloatingActionButton(
onPressed: () {
print('Close pressed');
},
child: Text('Close'),
)
)
],
推荐阅读
- sql - SQL Join 未按预期过滤 SSMS
- c# - 在 Unity3D 中控制游戏对象时传送
- reactjs - 在区块链上存储散列(存储在 ipfs 上的图像散列)
- reactjs - 用排序反应数据表列过滤器问题
- mysql - SQL - 选择列包含关键字并具有相同类别的记录
- javascript - 如何在 date-fns 中格式化小时和分钟?
- laravel - 默认路由不适用于 laravel 和 vue
- python - 如何返回由 Python 列表中的连续数字组成的最长子序列?
- javascript - 如何将未转义的字符串插值传递给脚本标签?
- java - Swagger 开放 API 定义不适用于 Micronaut JWT 安全 Micronaut 版本 2.2.1