gpt4 book ai didi

dart - 将扩展的 FAB 居中

转载 作者:IT王子 更新时间:2023-10-29 06:51:55 27 4
gpt4 key购买 nike

Extended FAB

您如何像 Material 设计规范那样将 Flutter 中提供的扩展 FAB 居中?

这里扩展的 FAB 是右对齐的:

new Scaffold(
floatingActionButton: new FloatingActionButton.extended(
onTap: () => {},
label: new Text('See all results')
}
)

最佳答案

您需要做的就是在 Scaffold 上设置 floatingActionButtonLocation 属性

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: ...
body: ...
floatingActionButton: MyFloatingActionButton(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat
);
}

class MyFloatingActionButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FloatingActionButton.extended(
icon: Icon(Icons.plus_one),
onPressed: () => {},
label: new Text('See all results'));
}
}

请注意这是问题的重复:Flutter - FloatingActionButton in the center

关于dart - 将扩展的 FAB 居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50314167/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com