如何让Flutter的Material Design 3 FAB像Material Design 2一样圆?

问题描述 投票:0回答:1

我尝试的代码是以下代码。

FloatingActionButton(
        onPressed: () {},
        backgroundColor: Colors.transparent,
        elevation: 0,
        child: Container(
          decoration: const BoxDecoration(
            shape: BoxShape.circle,
            color: Colors.blue,
          ),
          constraints: const BoxConstraints.expand(),
          child: const Icon(
            Icons.add,
            color: Colors.white,
          ),
        ),
      )
    

这张图片就是上面的代码。

我能够让它看起来几乎一样,但如果有更好的方法,请告诉我。

flutter material-ui material-design
1个回答
0
投票

在这种情况下,

FloatingActionButton
文档显示
shape
属性:)

floatingActionButton: FloatingActionButton(
  shape: const CircleBorder(),
  // ...
),
© www.soinside.com 2019 - 2024. All rights reserved.