Add Show Border to Image widget in Flutter Android iOS Example

The container widget in flutter supports decoration argument which accepts BoxDecoration() function with multiple values like border direction, border width and border color. To set a border around a image we need to wrap the Image widget component in a parent Container component and then apply the border on parent container widget. We can easily add border using this method in flutter on any widget. So in this tutorial we would Add Show Border to Image widget in Flutter Android iOS App Example.

Content in this project Add Show Border to Image Widget in Flutter Android iOS Example:

1. Open your project’s main.dart file and import material.dart package.

2. Call our main MyApp class using void main runApp function.

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

4. Defining the widget build method in MyApp class and make the App Bar.

5. Creating body argument in MyApp class. In the body section we would define all our widgets. First we would make a Center widget. Then inside the center widget we would make Row widget which supports multiple children.

6. In the Column widget now we would make a Parent widget Container and apply the border decoration on Container widget.

  • BoxDecoration : function supports multiple styling argument.
  • border – Border.all() : To set border around all image.
  • color : To set border color. I am passing here hex color code like (0xff – hex color code) format.
  • width : To set border width.

7. Creates the Image widget as child in parent container widget.

8. Complete source code for main.dart file:

Screenshot:

Add Show Border to Image widget in Flutter Android iOS Example

Leave a Reply

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