Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter move floatingActionButton up 50 pixels

Is it possible to move the floatingActionButton up by 50 pixels?

I have a floatingActionButton in an App that uses firebase_admob and the Ads Banner is overlapping on top of the floatingActionButton.

How does one set the floatingActionButton to be 50 pixels from the bottom of the screen?

From the documentation of floatingActionButton I can not seem to pick out how to position the button.

like image 978
Phuthib Avatar asked Jan 13 '19 19:01

Phuthib


2 Answers

Wrap your FloatingActionButton inside a Padding and add the size you want:

    floatingActionButton: Padding(             padding: const EdgeInsets.only(bottom: 50.0),             child: FloatingActionButton(               child: Icon(Icons.remove),               onPressed: () => null,             ),           ),  
like image 177
diegoveloper Avatar answered Sep 20 '22 00:09

diegoveloper


It's simple.

class Test extends StatelessWidget {   @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(),       body: Container(),       floatingActionButton: Align(           child: FloatingActionButton(onPressed: null),           alignment: Alignment(1, 0.7)),     );   } } 

Use Alignment, as everything is a Widget in Flutter.

like image 32
Doc Avatar answered Sep 21 '22 00:09

Doc