How to set margin for a Button in Flutter
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),
),
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.
Put your button inside a Container and then set the margin
Container(
margin: const EdgeInsets.only(top: 10.0),
child : RaisedButton(
onPressed: _submit,
child: Text('Login'),
),