Flutter - Padding

Padding可以给其子节点添加填充(留白),和边距效果类似

const Padding({
   
    super.key,
    required this.padding,
    super.child,
  }) : assert(padding != null);
  
  /// The amount of space by which to inset the child.
  final EdgeInsetsGeometry padding;

在定义中,必需传一个 padding 的规则

在 使用 EdgeInsetsGeometry 时 我们通常会使用 他的子类 EdgeInsets

EdgeInsets

fromLTRB(double left, double top, double right, double bottom):分别指定四个方向的填充。
all(double value) : 所有方向均使用相同数值的填充。
only({
   left, top, right ,bottom }):可以设置具体某个方向的填充(可以同时指定多个方向)symmetric({
    vertical, horizontal }):用于设置对称方向的填充,vertical指top和bottom,horizontal指left和right

使用起来也比较简单

// 为`Text("Padding")` 添加一个 左15 底20的边距
 Padding(
 padding: EdgeInsets.only(left: 15,bottom: 20),
 child: Text("Padding"),
 ),

在这里插入图片描述

其他示例
在这里插入图片描述

import 'package:flutter/material.dart';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值