border method

Widget border({
  1. Key? key,
  2. double? all,
  3. double? left,
  4. double? right,
  5. double? top,
  6. double? bottom,
  7. Color color = const Color(0xFF000000),
  8. BorderStyle style = BorderStyle.solid,
})

边框

Implementation

Widget border({
  Key? key,
  double? all,
  double? left,
  double? right,
  double? top,
  double? bottom,
  Color color = const Color(0xFF000000),
  BorderStyle style = BorderStyle.solid,
}) {
  BoxDecoration decoration = BoxDecoration(
    border: Border(
      left: (left ?? all) == null
          ? BorderSide.none
          : BorderSide(color: color, width: left ?? all ?? 0, style: style),
      right: (right ?? all) == null
          ? BorderSide.none
          : BorderSide(color: color, width: right ?? all ?? 0, style: style),
      top: (top ?? all) == null
          ? BorderSide.none
          : BorderSide(color: color, width: top ?? all ?? 0, style: style),
      bottom: (bottom ?? all) == null
          ? BorderSide.none
          : BorderSide(color: color, width: bottom ?? all ?? 0, style: style),
    ),
  );
  return DecoratedBox(
    key: key,
    child: this,
    decoration: decoration,
  );
}