Add Apply Margin to Image Widget in Flutter Android iOS Example

Image widget did not support margin property directly but using the Container widget we can easily apply Margin property on Image widget for all 4 Left, Right, Top and Bottom side. Margin is one of the most usable property for development purpose because using the margin we can easily set empty space around a Image so the Image won’t touch or disturb other widgets. So in this tutorial we would Add Apply Margin to Image Widget in Flutter Android iOS Example Tutorial.

Contents in this project Add Apply Margin to Image Widget 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 here we would call our main Root MyApp class.

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

4. Now we would create Widget Build area in MyApp class. In widget build are we would first create the App bar then in body section we would create the Center widget. Now we would make the Row widget in Center widget because i will apply margin on 2 images and for two widgets we have to use Multiple children supported widget.

5. Creating 2 Container widget with 2 Images widget wrap inside it. We are calling the image from online HTTP URL.

  • margin : We would use the EdgeInsets.fromLTRB() parameter. Here the LTRB means Left, Top, Right and Bottom. We have to pass 4 double float type values here which used for 4 different directions.

6. Complete source code for main.dart file:

Screenshot:

Add Apply Margin to Image Widget in Flutter Android iOS Example

Leave a Reply

Your email address will not be published.