【问题标题】:how to make FloatingActionButton center align如何使 FloatingActionButton 居中对齐
【发布时间】:2020-09-08 19:41:02
【问题描述】:
 Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: <Widget>[
          Expanded(
            child: Image.asset('images/ball$go.png'),
          ),
          FloatingActionButton(
            onPressed: () {
              setState(() {
                go = Random().nextInt(5) + 1;
              });
            },
            child: Text('Ask'),
            backgroundColor: Colors.blue.shade300,
            foregroundColor: Colors.black,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(
                Radius.circular(16.0),
              ),
            ),
            elevation: 20.0,
          ),
        ],
      ),
    );
  }
}

【问题讨论】:

标签: flutter alignment center floating-action-button


【解决方案1】:

使用对齐小部件包装

   Align(
          alignment: Alignment.center,
          child: FloatingActionButton(
            onPressed: () {
              setState(() {

              });
            },
            child: Text('Ask'),
            backgroundColor: Colors.blue.shade300,
            foregroundColor: Colors.black,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(
                Radius.circular(16.0),
              ),
            ),
            elevation: 20.0,
          ),
        ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-01
    • 2013-05-24
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    相关资源
    最近更新 更多