Search code examples
flutterfloating-action-button

Position two floating action button in Flutter


How can I position multiple floating action button in Flutter. In particular I need one button in the bottom-right of the screen and another one in the top left.


Solution

  • Check the below code and screenshot may be this will help you :

    enter image description here

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text(widget.title),
          ),
          body: Column(
            children: <Widget>[
              Expanded(
                  child: Container(
                    width: MediaQuery.of(context).size.width,
                    color: Colors.red,
                    child: Align(
                      alignment: Alignment.topLeft,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          FloatingActionButton(onPressed: (){},child: Icon(Icons.add),),
    
                        ],
                      ),
                    ),
                  )
              ),
              Expanded(child: Container(
                  width: MediaQuery.of(context).size.width,
                  color: Colors.green,
                  child: Text('Center',textAlign: TextAlign.center,)
              )),
              Expanded(
                  child: Container(
                    width: MediaQuery.of(context).size.width,
                    color: Colors.red,
                    child: Align(
                      alignment: Alignment.bottomRight,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: <Widget>[
                          FloatingActionButton(onPressed: (){},child: Icon(Icons.add),),
                        ],
                      ),
                    ),
                  )
              ),
    
            ],
          ),
        );
      }