添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

flutter floating button size

Flutter中的FloatingActionButton(浮动按钮)的大小可以使用其构造函数中的参数进行自定义。

FloatingActionButton的默认大小是56.0 x 56.0像素,可以通过设置其高度和宽度属性来更改其大小。例如,如果要将FloatingActionButton的大小更改为48 x 48像素,可以在其构造函数中添加height和width属性,如下所示:

FloatingActionButton(
  onPressed: () {},
  child: Icon(Icons.add),
  backgroundColor: Colors.blue,
  height: 48,
  width: 48,

除了使用固定的值来设置大小,还可以使用MediaQuery来根据屏幕大小动态调整FloatingActionButton的大小。例如,以下代码会将FloatingActionButton的大小设置为屏幕宽度的10%:

final screenWidth = MediaQuery.of(context).size.width;
final buttonSize = screenWidth * 0.1;
FloatingActionButton(
  onPressed: () {},
  child: Icon(Icons.add),
  backgroundColor: Colors.blue,
  height: buttonSize,
  width: buttonSize,

希望这些信息能对您有所帮助!

  •