Is it possible to make the FloatingActionButton
in the centre instead of the right side?
import 'package:flutter/material.dart'; import 'number.dart'; import 'keyboard.dart'; class ContaPage extends StatelessWidget { @override Widget build(BuildContext context) => new Scaffold( body: new Column( children: <Widget>[ new Number(), new Keyboard(), ], ), floatingActionButton: new FloatingActionButton( elevation: 0.0, child: new Icon(Icons.check), backgroundColor: new Color(0xFFE57373), onPressed: (){} ) ); }
The above examples are great, but if you want to have full control over the exact location of the floating action button, you should wrap your FloatingActionButton widget with Align widget and use Alignment(x axis, y axis) to set the exact location.
How to Disable Button in Flutter. To disable button in Flutter, just assign the null value to the onPressed parameter of the Button.
I don't know if this was added since this question was first answered, but there's now floatingActionButtonLocation
property on the Scaffold
class.
It would work like this in your original question:
class ContaPage extends StatelessWidget { @override Widget build(BuildContext context) => new Scaffold( // ... floatingActionButton: new FloatingActionButton( // ...FloatingActionButton properties... ), // Here's the new attribute: floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); }
Also see the documentation:
Scaffold
class (search floatingActionButtonLocation
): https://docs.flutter.dev/flutter/material/Scaffold-class.html FloatingActionButtonLocation
class: https://docs.flutter.dev/flutter/material/FloatingActionButtonLocation-class.html With the new flutter API you do that very easily just change the floatingActionButtonLocation
property in the Scaffold to
FloatingActionButtonLocation.centerFloat
Example :
return new Scaffold( floatingActionButton: new FloatingActionButton( child: const Icon(Icons.add), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, bottomNavigationBar: new BottomAppBar( color: Colors.white, child: new Row(...), ), );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With