Search code snippets, questions, articles...

Add padding to container in Flutter

Container(
    padding: EdgeInsets.all(50.0),
    child: Text(
        'Hello world'
    ),
),

To add padding or insert space inside part of the container in flutter you can use 'padding' property. As shown in the above code snippet we have added a padding of '50.0' from all edges to the container. 

Was this helpful?
1 Comments

The above code snippet will add padding from all sides symmetrically. To add different padding from specific sides use below code

Container(
    padding: EdgeInsets.only(top: 100.0, left: 50.0, right: 30.0, bottom: 20.0),
    child: Text(
        'Hello world'
    ),
),

To add padding horizontally or vertically in symmetric, use

Container(
    padding: EdgeInsets.symmetric(horizontal: 100.0, vertical: 50.0),
    child: Text(
        'Hello world'
    ),
),