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

4

FloatingActionButton

如何使遮挡ListViewFloatingActionButton的背景透明?

这是我的代码:

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

这是 Scaffoldbody 结构:
body : new Column (
           children : <Widget>[
               new Expanded (
                   child : new ListView.builder() //ListView.builder
               ), //Expanded

               new FloatingActionButton () //FloatingActionButton
           ] //<Widget>[]
        ) //Column

我还尝试使用Container将其包装,然后应用容器的背景透明,但这没有起作用。

还有如何将其对齐到父级(Scaffoldbody)的底部或末端?


你如何使用 FloatingActionButton?如果它在 floatingActionButton: Scaffold 属性中使用,正如其名称所示,它会浮动在主体上方,因此您不需要做任何特殊处理。 - chemamolins
@chemamolins 在Scaffold内部,有一个appBar,在body内部,主要的小部件是Column,在Column内部,第一个小部件是包含ListViewExpanded,第二个小部件是FloatingActionButton - Detained Developer
1个回答

4
您应该在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),
      ),
    );
  }

我该如何放置多个FloatingActionButtonsScaffold似乎不能接受多个。 - Detained Developer
2
您可以在 floatingActionButton: 属性中使用列或行。并在其中放置两个 FloatingActionButton 小部件。 - chemamolins

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接