Created
November 9, 2019 13:34
-
-
Save tchafack/39a9c24ad1cd1ad376c34bc3aea2ef57 to your computer and use it in GitHub Desktop.
[Flutter, Dart] Multiple FloatingActionButton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class MultiFloatingButton extends StatefulWidget { | |
@override | |
_MultiFloatingButtonState createState() => _MultiFloatingButtonState(); | |
} | |
class _MultiFloatingButtonState extends State<MultiFloatingButton> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.white, | |
appBar: AppBar( | |
title: Text('Float'), | |
centerTitle: true, | |
), | |
body: Container( | |
), | |
floatingActionButton: Stack( | |
children: <Widget>[ | |
Positioned( | |
bottom: 80.0, | |
right: 10.0, | |
child: FloatingActionButton( | |
heroTag: 'save', | |
onPressed: () { | |
// What you want to do | |
}, | |
child: Icon(Icons.save), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(5.0), | |
), | |
), | |
), | |
Positioned( | |
bottom: 10.0, | |
right: 10.0, | |
child: FloatingActionButton( | |
heroTag: 'close', | |
onPressed: () {}, | |
child: Icon(Icons.close), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(5.0), | |
), | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Happy to help :)
thank you so much
awesome ✅
Thanks a ton for this!
This worked for me .
return MaterialApp(
home:
Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
title: Text('$i'),
centerTitle: true,
backgroundColor: Colors.green,
),
body: Stack(
children: <Widget>[
Align(
alignment: Alignment.bottomLeft,
child: FloatingActionButton(
onPressed: (){
//todo
},
child: Icon(Icons.remove), ),
),
Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton(
child: Icon(Icons.add),
onPressed: (){
//todo
}, ), ),
Align(
alignment: Alignment.center ,
child: FloatingActionButton(
child: Text('Reset'),
onPressed: (){
//todo
},
),
),
],
),
),
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. it worked for me.