是否可能将floatingActionButton
上移50像素?
我的应用程序中有一个floatingActionButton
,使用了firebase_admob
,广告横幅覆盖在floatingActionButton
上面。
如何将floatingActionButton
设置为距离屏幕底部50像素?
根据floatingActionButton
的文档,我似乎找不到如何定位按钮的方法。
是否可能将floatingActionButton
上移50像素?
我的应用程序中有一个floatingActionButton
,使用了firebase_admob
,广告横幅覆盖在floatingActionButton
上面。
如何将floatingActionButton
设置为距离屏幕底部50像素?
根据floatingActionButton
的文档,我似乎找不到如何定位按钮的方法。
将您的FloatingActionButton
包装在一个Padding中,并添加所需的大小:
floatingActionButton: Padding(
padding: const EdgeInsets.only(bottom: 50.0),
child: FloatingActionButton(
child: Icon(Icons.remove),
onPressed: () => null,
),
),
很简单。
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(),
floatingActionButton: Align(
child: FloatingActionButton(onPressed: null),
alignment: Alignment(1, 0.7)),
);
}
}
在Flutter中,万物皆是Widget,因此使用对齐方式(Alignment)。