Add Set Margin for Raised Button in Flutter Android iOS Example

Margin property is used to set empty space around a object or Widget in Flutter. Most of flutter widgets directly dose not support margin property but using the Child Wrapping technique we can apply margin to any widget in flutter using Container widget. Container widget support margin property with all the Left, Top, Right and Bottom side. So in this tutorial we would Add Set Margin for Raised Button in Flutter Android iOS Example Tutorial.

Contents in this project Add Set Margin for Raised Button in Flutter Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Create void main runApp() method and call our main Root parent class named as MyApp here.

3. Create our main class named as MyApp extends with StatelessWidget.

4. Create a Random function with some print log message in MyApp class. We would call this function on button onPress event.

5. Create widget build area in MyApp class. Here we would first make the Scaffold widget in MaterialApp widget . Then we would make a Center widget -> Column widget. We would put our button inside the Column widget.

6. Creating the Container widget and put the Raised Button inside the Container widget as Child. We would apply the margin on Container widget and it will automatically apply on the child button widget.

  • margin : Used to set the margin around the child widget.
  • EdgeInsets.fromLTRB() : Here LTRB means Left, Top, Right and Bottom side.

7. Complete source code for main.dart file:

Screenshot:

Add Set Margin for Raised Button in Flutter Android iOS Example

2 Comments

  1. create one page in that page top middle we have to keep WELCOME and right side end drawer and in middle company logo and after we have to raise three raised button and after one empty box and after buttom navigation bar, can any one help me with this, i am new to flutter.

Leave a Reply

Your email address will not be published. Required fields are marked *