Flutter 自习室 EdgeInsetsGeometry

495 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

EdgeInsets

四周的偏移量用于Padding

image-20220106173134383

EdgeInsets.all

所有的偏移量都固定为同一个值

四周偏移 8 像素

EdgeInsets.all(8.0)

image-20220107100447598

EdgeInsets.symmetric

水平或者垂直方向偏移相同的值

垂直方向偏移 8 像素

EdgeInsets.symmetric(vertical: 8.0)

image-20220107100534160

竖直方向偏移 8 像素

EdgeInsets.symmetric(horizontal: 8.0)

image-20220107100758360

四周偏移 8 像素

EdgeInsets.symmetric(horizontal: 8, vertical: 8)

image-20220107100447598

EdgeInsets.fromLTRB

分别为 Left Top Right Bottom 指定对应的偏移量

Left = 5 Top = 8 Right = 7 Bottom = 3

EdgeInsets.fromLTRB(5,8,7,3)

image-20220107101249360

EdgeInsets.only

可以针对单个或者多个设置偏移

Left = 8

EdgeInsets.only(left:8)

image-20220107101349770

Right = 4 Bottom = 5

EdgeInsets.only(right:4, bottom:5)

image-20220107101455359