大盒子下(Container) 的小盒子会自动填充到我们设置的内边距
Padding 元素 必须设置 padding 属性
padding 的值 有
- EdgeInsets.fromLTRB(10, 30, 50, 10) 四个方向分别设置值 按 left、top、right、bottom 的顺序
- EdgeInsets.all(30) 四个方向都是同样的值
- EdgeInsets.only(top: 30) 只设置一个方向的值
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Welcome to Flutter',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Welcome to Flutter12'),
),
body: Container(
width: 300,
height: 500,
color: Colors.red,
child: Padding(
padding: EdgeInsets.fromLTRB(10, 30, 50, 10),
child: Container(
color: Colors.blue,
),
),
),
),
);
}
}