Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set FloatingActionButton's background transparent in flutter?

FloatingActionButton

How to set the background of FloatingActionButton transparent which is blocking the ListView ?

Here is my code :

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

Here is the structure of body of Scaffold :

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

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

I also tried wrapping it with a Container and then applying container's background transparent, but it didn't work.

And also how to align it to the bottom|end of parent (body of Scaffold) ?

like image 377
Detained Developer Avatar asked Sep 12 '25 13:09

Detained Developer


1 Answers

You should set it in the floatingActionButton: Scaffold property, as in the example project created by flutter create command.

  @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),
      ),
    );
  }
like image 85
chemamolins Avatar answered Sep 14 '25 03:09

chemamolins