How To Add Text Padding Widget In Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 06-10-2020

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.

How To Add Text Padding Widget In Flutter Android App

Add Text Padding Widget 

Step 1: Text Padding Widget

Column(
    children: <Widget>[
      Center(child:Container(
          padding: EdgeInsets.fromLTRB(22, 22, 22, 22),
          child: Text('Padding Container Widget',
              style: TextStyle(fontSize: 22)))),

      Padding(
          padding: EdgeInsets.fromLTRB(15, 20, 15, 20),
          child: Text('Padding Widget',
              style: TextStyle(fontSize: 22))),
    ]
)


Complete Code For Text Padding WIdget In Flutter
Main.dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
            appBar: AppBar(
              centerTitle: true,
              backgroundColor: Colors.cyan,
              title: Text("Padding Widget"),
            ),
            body: Column(
                children: <Widget>[
                  Center(child:Container(
                      padding: EdgeInsets.fromLTRB(22, 22, 22, 22),
                      child: Text('Padding Container Widget',
                          style: TextStyle(fontSize: 22)))),

                  Padding(
                      padding: EdgeInsets.fromLTRB(15, 20, 15, 20),
                      child: Text('Padding Widget',
                          style: TextStyle(fontSize: 22))),
                ]
            )
        )
    );
  }
}

Related Post