Reputation: 171
class app1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return (MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Hello ',
home: Material(
child: Container (
alignment: Alignment.topCenter ,
//padding: EdgeInsets.all (30 ),
margin: EdgeInsets.all(30),
child: Row(
children: <Widget> [
Text ( 'Hello There ' , style: TextStyle (fontSize: 30 ) ),
],
),
),
),
)
);
}
}
I have a text widget when i apply the margin and after that apply the padding same result ? so what's the different ?
Upvotes: 3
Views: 13577
Reputation: 186
Padding: is the inner space of the element to the edge
Margin: is the space between widgets together
Upvotes: 14
Reputation: 4750
Easy Method :
**Padding is Space Around means in the container .
Margin is Space outside means out side of the container**
Upvotes: 3
Reputation: 555
Margin is the space around the widget. For example, from the edge of the container to the edge of the phone screen.
Padding is the space within the widget. For example, from the edge of the container to the text in it.
Check out this video from the flutter team around 0:40 to see a quick visual. https://api.flutter.dev/flutter/widgets/Container-class.html
Upvotes: 3