FlutterにてWidgetの間隔をあけたり余白を作りたい時にpaddingやmarginを使います
Padding
padding では EdgeInsets を使って設定します
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  | 
						// 上下左右に50.0のマージンを付ける padding: EdgeInsets.all(50.0) // Left: 120, Top: 30, Right: 60, Bottom: 50  padding: EdgeInsets.fromLTRB(120, 30, 60, 50) // 水平、左右に50 padding: EdgeInsets.symmetric(horizontal: 50) // 垂直、上下に50 padding: EdgeInsets.symmetric(vertical: 50) // leftなど各辺だけの設定 padding: EdgeInsets.only(left: 50.0) padding: EdgeInsets.only(top: 50.0) padding: EdgeInsets.only(right: 50.0) padding: EdgeInsets.only(bottom: 50.0)  | 
					
EdgeInsets.all
プロジェクトのテンプレートの Empty Applicationを修正して padding を入れてみます
Card の中に’Text’を入れて背景色で位置がわかりやすくします
main.dart
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41  | 
						import 'package:flutter/material.dart'; void main() {   runApp(const MainApp()); } class MainApp extends StatelessWidget {   const MainApp({super.key});   @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: const Text('Padding Test'),           backgroundColor: Colors.grey,         ),         body: const Card(           color: Colors.lightGreenAccent,           child: Padding(             padding: EdgeInsets.all(50.0),             // padding: EdgeInsets.fromLTRB(120, 30, 60, 50),             // padding: EdgeInsets.symmetric(horizontal: 50),             // padding: EdgeInsets.symmetric(vertical: 50),             //  padding: EdgeInsets.only(left: 100.0),             //  padding: EdgeInsets.only(top: 100.0),             //  padding: EdgeInsets.only(right: 50.0),             //  padding: EdgeInsets.only(bottom: 150.0),             child: Text(               'Text',               style: TextStyle(                 fontSize: 32,                 backgroundColor: Colors.green,                ),             ),           ),         ),       ),     );   } }  | 
					
EdgeInsets.all(50.0)
これで実行してみると
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
Cardの背景色と枠がなければ
テキストの余白ができたように見えます
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
EdgeInsets.fromLTRB
上下左右を個別に設定したい場合は、
| 
					 1 2  | 
						// Left: 120, Top: 30, Right: 60, Bottom: 50  padding: EdgeInsets.fromLTRB(120, 30, 60, 50)  | 
					
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
EdgeInsets.symmetric
| 
					 1 2  | 
						// 水平、左右に50  padding: EdgeInsets.symmetric(horizontal: 50)  | 
					
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
| 
					 1 2  | 
						// 垂直、上下に50  padding: EdgeInsets.symmetric(vertical: 50)  | 
					
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
EdgeInsets.only
| 
					 1 2  | 
						// leftだけの設定 padding: EdgeInsets.only(left: 50.0)  | 
					
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
rightやbottomは画面上何もないように見えますが、大きな値に設定するとこのようになってしまいます
| 
					 1 2  | 
						// rightだけの設定  padding: EdgeInsets.only(right: 350.0)  | 
					
![[Flutter] Padding と EdgeInsets で余白の設定 1x1.trans - [Flutter] Padding と EdgeInsets で余白の設定](https://akira-watson.com/wp-content/themes/simplicity2/images/1x1.trans.gif)
margin はこちらを参考に
Margin と EdgeInsets で余白の設定
 
 
 
References:
Padding class
Padding class – widgets library – Dart API