如何在Flutter中将FloatingActionButton的背景设置为透明?

时间:2018-09-30 07:44:23

标签: android dart flutter

FloatingActionButton

如何将FloatingActionButton的背景设置为透明,从而阻止ListView

这是我的代码:

FloatingActionButton(
    isExtended: false,
    backgroundColor: Colors.blue,
    foregroundColor: Colors.white,
    child: new Icon(Icons.add),
    onPressed: () {}
)

这是body的{​​{1}}的结构:

Scaffold

我还尝试用body : new Column ( children : <Widget>[ new Expanded ( child : new ListView.builder() //ListView.builder ), //Expanded new FloatingActionButton () //FloatingActionButton ] //<Widget>[] ) //Column 包装它,然后以透明的方式应用容器的背景,但是没有用。

还有如何使其与父级{{1}的Container)的bottom|end对齐?

1 个答案:

答案 0 :(得分:1)

您应该在floatingActionButton: Scaffold属性中进行设置,就像在flutter create命令创建的示例项目中一样。

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(),
      floatingActionButton: new FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ),
    );
  }
相关问题