padding container flutter code example

Example 1: how to add padding flutter

Padding(
	// Even Padding On All Sides
    padding: EdgeInsets.all(10.0),
    // Symetric Padding
    padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 5.0),
    // Different Padding For All Sides
    padding: EdgeInsets.fromLTRB(1.0, 2.0, 3.0, 4.0);
    
    child: Child
    (
    	...
    ),
)

Example 2: flutter container margin

@override
Widget build(BuildContext context) {
  return Scaffold(
    backgroundColor: Colors.white,
    body: Container(
      margin: const EdgeInsets.only(left: 20.0, right: 20.0),
      child: Container(),
    ),
  );
}

Example 3: flutter padding

const Card(
  child: Padding(
    padding: EdgeInsets.all(16.0),
    child: Text('Hello World!'),
  ),
)

Tags:

Misc Example