首页 文章

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

提问于
浏览
1

FloatingActionButton

如何设置阻止ListViewFloatingActionButton透明背景?

这是我的代码:

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

这是Scaffold Scaffold的结构:

body : new Column (
           children : <Widget>[
               new Expanded (
                   child : new ListView.builder() //ListView.builder
               ), //Expanded

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

我也尝试用Container包装它然后应用容器的背景透明,但它不起作用。

以及如何将它与父级的bottom|end(bodyScaffold)对齐?

1 回答

  • 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),
          ),
        );
      }
    

相关问题