toDecoratedBox method

Widget toDecoratedBox({
  1. Color? bgColor,
  2. ImageProvider<Object>? bgImage,
  3. BoxShape? boxShape,
  4. BorderRadius? borderRadius,
  5. Border? border,
  6. bool? inFrontOfChild,
  7. bool? hasShadow,
})

create a decorated container (without size altered)

Implementation

Widget toDecoratedBox({
  Color? bgColor,
  ImageProvider<Object>? bgImage,
  BoxShape? boxShape,
  BorderRadius? borderRadius,
  Border? border,
  bool? inFrontOfChild,
  bool? hasShadow,
}) =>
    DecoratedBox(
      decoration: BoxDecoration(
          color: bgColor,
          image: bgImage != null ? DecorationImage(image: bgImage, fit: BoxFit.cover) : null,
          shape: boxShape ?? BoxShape.rectangle,
          borderRadius: borderRadius,
          border: border,
          boxShadow: (hasShadow ?? false)
              ? [
                  BoxShadow(
                      color: Colors.black.withOpacity(0.3),
                      blurRadius: 3,
                      spreadRadius: 0.5,
                      offset: const Offset(0, 3))
                ]
              : null),
      position: (inFrontOfChild ?? false)
          ? DecorationPosition.foreground
          : DecorationPosition.background,
      child: this,
    );