How to set margin for a Button in Flutter
Put your button inside a Container and then set the margin
new Container( margin: const EdgeInsets.only(top: 10.0), child : new RaisedButton( onPressed: _submit, child: new Text('Login'), ),
Alternatively you can wrap your button with Padding. (That is what Container does internally.)
Padding( padding: const EdgeInsets.all(20), child: ElevatedButton( onPressed: _submit, child: Text('Login'), ),);
See this answer more more on adding margin to a widget.
Note: RaisedButton
is deprecated as of Flutter 2.0. ElevatedButton
is the replacement.
In Flutter 2.0, RaisedButton was deprecated, The ElevatedButton is replacement.
So you can use ElevatedButton and set style as bellow to remove margin:
ElevatedButton.icon( onPressed: () {}, icon: Icon(Icons.add), label: Text( 'Add Place', ), style: ButtonStyle(tapTargetSize: MaterialTapTargetSize.shrinkWrap), ),