toEdgeInsets property
EdgeInsets?
get
toEdgeInsets
将数组转为内边距对象,其数组结构与 CSS 一致:
10- 所有10, 20- 上下 | 左右10, 20, 10- 上 | 左右 | 下10, 20, 10, 20- 上 | 右 | 下 | 左
Implementation
EdgeInsets? get toEdgeInsets {
if (isEmpty) return null;
if (length == 1) {
return EdgeInsets.all(first);
} else if (length == 2) {
return EdgeInsets.symmetric(vertical: first, horizontal: last);
} else {
if (length == 3) {
return EdgeInsets.only(
top: this[0],
left: this[1],
right: this[1],
bottom: this[2],
);
} else {
return EdgeInsets.only(
top: this[0],
right: this[1],
bottom: this[2],
left: this[3],
);
}
}
}