Flutterflutter

Flutter EdgeInsets

2021-04-26  本文已影响0人  Victory_886

我写这个原因是不想一行代码太长,也每次都写 某一个 上、下、左、右等,觉得你能用到你就拿过去用吧。

纯属个人爱好写的

代码如下:

/// 上边 间距
insetT(double t) => EdgeInsets.only(top: t);

/// 左边 间距
insetL(double l) => EdgeInsets.only(left: l);

/// 右边 间距
insetR(double r) => EdgeInsets.only(right: r);

/// 下边 间距
insetB(double b) => EdgeInsets.only(bottom: b);

/// 左、上 间距
insetLT(double l, double t) => EdgeInsets.only(left: l, top: t);

/// 右、上 间距
insetRT(double r, double t) => EdgeInsets.only(right: r, top: t);

/// 左、右 间距
insetLR(double l, double r) => EdgeInsets.only(left: l, right: r);

/// 上、下 间距
insetTB(double t, double b) => EdgeInsets.only(top: t, bottom: b);

/// 左、下 间距
insetLB(double l, double b) => EdgeInsets.only(left: l, bottom: b);

/// 右、下 间距
insetRB(double r, double b) => EdgeInsets.only(right: r, bottom: b);

/// 上,下、左 间距
insetTBL(double t, double b, double l) =>
    EdgeInsets.only(left: l, top: t, bottom: b);

/// 上,下、右 间距
insetTBR(double b, double r, double t) =>
    EdgeInsets.only(bottom: b, right: r, top: t);

/// 左,右、上 间距
insetLRT(double l, double r, double t) =>
    EdgeInsets.only(left: l, right: r, top: t);

/// 左,右、下 间距
insetLRB(double l, double r, double b) =>
    EdgeInsets.only(left: l, right: r, bottom: b);

/// 圆、边框、颜色
circleDecoration(
  double r,
  double w,
  Color color, [
  Color bgColor,
]) =>
    BoxDecoration(
      color: bgColor ?? Colors.transparent,
      borderRadius: BorderRadius.circular(r),
      border: Border.all(width: w, color: color),
    );

其它Flutter 封装:
Text 传送门一
Container 传送门二
随机颜色:传送门三

谢谢~

上一篇下一篇

猜你喜欢

热点阅读