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,
  9. bool animate = false,
})

Implementation

Widget border({
  Key? key,
  double? all,
  double? left,
  double? right,
  double? top,
  double? bottom,
  Color color = const Color(0xFF000000),
  BorderStyle style = BorderStyle.solid,
  bool animate = false,
}) {
  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 animate
      ? _StyledAnimatedBuilder(
          key: key,
          builder: (animation) {
            return _AnimatedDecorationBox(
              child: this,
              decoration: decoration,
              duration: animation.duration,
              curve: animation.curve,
            );
          },
        )
      : DecoratedBox(
          key: key,
          child: this,
          decoration: decoration,
        );
}