By default floating action button is at the right side of the screen. I know about the floatingActionButtonLocation
and its properties like endDocked
, startDocked
, centerDocked
, but none of them helped me in moving it to the left side of the screen.
6 Answers
You can just add into your Scaffold the named constructor:
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat
or
floatingActionButtonLocation: FloatingActionButtonLocation.startDocked
Take the getting started app for example:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
//##########################################################################
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
//##########################################################################
/*
or
`floatingActionButtonLocation: FloatingActionButtonLocation.startDocked`
*/
);
}
}

- 113
- 1
- 5
I believe this previously provided answer provides the closest "Easy to Implement" set of options to your problem.
https://stackoverflow.com/a/49761700/10768398
The answer basically says to use something similar to the following on your Scaffold component of your Widget tree:
, floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat
Based on the descriptions of the options it doesn't look like there is an align to the left.
Also take a look at the available options here:
https://api.flutter.dev/flutter/material/FloatingActionButtonLocation-class.html

- 783
- 7
- 21
-
ya, I saw it. But it suggests for how to implement a floating action button on Center. And I want it to left side of the screen. But thanks for respond. – Jay Tillu Jul 25 '19 at 18:11
-
I added a bit to the answer, I don't think there is an align left option – E.Bradford Jul 25 '19 at 18:11
-
Yes Sir, I just noticed your edit. I totally agree that by default there is not a left alignment option. – Jay Tillu Jul 25 '19 at 18:13
-
1Just a thought, but would a Stack object (with an array of widgets In the stack) and with one of the children having a Positioned widget (your desired button) work in your case? – E.Bradford Jul 25 '19 at 18:22
-
I didn't try it yet. But as you suggest I'll try it as well. – Jay Tillu Jul 25 '19 at 18:28
-
It might qualify as a solution if you do not require scrolling on that particular screen. Scrolling would scroll the button completely off the screen. – E.Bradford Jul 25 '19 at 18:45
This will place your FAB in the lower lefthand corner:
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.startDocked,
floatingActionButton:
FloatingActionButton(heroTag: null, onPressed: () {}),
);
See https://api.flutter.dev/flutter/material/FloatingActionButtonLocation/startDocked-constant.html

- 1,046
- 12
- 13
-
Is there a way to add padding or a margin to the docked button so it's not as close to the edge of the screen? – Ian Smith Jan 30 '21 at 21:42
I used following code to make the floatingActionButton on left side by using padding on right side of FAB.
floatingActionButton: Padding(
padding: const EdgeInsets.only(right: 275.0),
child: FloatingActionButton(
child: Icon(
Icons.add,
color: Colors.black,
),
backgroundColor: Colors.orange,
onPressed: (){},
),
),

- 81
- 1
- 11
-
1I suggest to avoid this technique as you have different screen sizes and it the feeling will be different across devices. – Saar Oct 04 '20 at 16:51
Basically suggested by @E.Bradford in the comment above, but I wanted to provide some code, if needed. You can place the FloatingActionButton pretty much anywhere you want by stacking it into a positioned widget.
Stack(
children: [
Placeholder(),
Positioned(
left: 40,
bottom: 40,
child: FloatingActionButton(
onPressed: () {},
),
),
],
)

- 12,831
- 4
- 56
- 53
You can wrap your floatingActionButton
with Row()
and give crossAxisAlignment
to center:
floatingActionButton: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left:25.0),
child: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
},
child: Icon(Icons.message,color: Colors.white,),
backgroundColor: Colors.green,
),
),
],
),

- 7,102
- 69
- 48
- 77

- 46
- 2