Add Padding to Text Widget Text in Flutter Android iOS Example

Padding is used to set space between Text content and defined text content area. Its like a margin type but only applied on Text to set space between border defined area. There are two ways to set Padding in flutter first is using the Padding Widget and second is Wrap the Text widget in container widget and apply the padding on Container widget. We would discuss the both example in our current tutorial. So in this tutorial we would Add Padding to Text Widget Text in Flutter Android iOS Example Tutorial.

Contents in this project Add Padding to Text Widget Text 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 MyApp class with it.

3. Create our main root view class named as MyApp extends with State less widget.

4. Create Column widget in Scaffold widget build area.

5. Creating a Container widget in Column widget and make a child Text widget in Container widget. Here we would use the padding property with EdgeInsets.fromLTRB() property. Here LTBR means left, right, top and bottom.

6. Creating Padding widget and make a Text widget as child in Padding widget. Here we are using the padding property with EdgeInsets.fromLTRB() parameter.

7. Complete source code for main.dart file:

Screenshot:

Add Padding to Text Widget Text in Flutter Android iOS Example

Leave a Reply

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