一、Flutter Padding 组件介绍
Padding在Flutter中常用组件之一,用于处理容器与其子元素之间的间距,功能单一,Flutter中并没有单独的Margin控件,
二、Padding 构造属性
const Padding({
Key key,
@required this.padding, // 间距
Widget child, // 子组件
})
三、代码演示
import 'package:flutter/material.dart';
class PaddingPage extends StatefulWidget {
PaddingPage({Key key}) : super(key: key);
@override
_PaddingPageState createState() => _PaddingPageState();
}
class _PaddingPageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("56zhiyi.com padding组件"),
),
body: Padding(
padding: EdgeInsets.all(10),
child: Container(
width: 100,
height: 100,
decoration:
BoxDecoration(border: Border.all(width: 1, color: Colors.red)),
child: Text("padding 组件演示"),
),
),
);
}
}
效果图