gpt4 book ai didi

dart - Flutter - 中心的 FloatingActionButton

转载 作者:IT老高 更新时间:2023-10-28 12:33:38 26 4
gpt4 key购买 nike

是否可以将 FloatingActionButton 放在中间而不是右侧?

import 'package:flutter/material.dart';
import 'number.dart';
import 'keyboard.dart';

class ContaPage extends StatelessWidget {
@override
Widget build(BuildContext context) => new Scaffold(
body: new Column(
children: <Widget>[
new Number(),
new Keyboard(),
],
),
floatingActionButton: new FloatingActionButton(
elevation: 0.0,
child: new Icon(Icons.check),
backgroundColor: new Color(0xFFE57373),
onPressed: (){}
)
);
}

enter image description here

最佳答案

自从第一次回答这个问题以来,我不知道这是否被添加,但现在 Scaffold 类上有 floatingActionButtonLocation 属性。

在你原来的问题中会这样工作:

class ContaPage extends StatelessWidget {
@override
Widget build(BuildContext context) => new Scaffold(
// ...

floatingActionButton: new FloatingActionButton(
// ...FloatingActionButton properties...
),

// Here's the new attribute:

floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}

另见文档:

关于dart - Flutter - 中心的 FloatingActionButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44713501/

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