decoration method

  1. @widgetFactory
Widget decoration({
  1. Color? color,
  2. DecorationImage? image,
  3. Gradient? gradient,
  4. List<BoxShadow>? shadows,
  5. BoxBorder? border,
  6. BorderRadiusGeometry? borderRadius,
  7. BlendMode? backgroundBlendMode,
  8. BoxShape? boxShape,
  9. ShapeBorder? shape,
  10. Decoration? decoration,
  11. DecorationPosition position = DecorationPosition.background,
})

Paints a decoration either after (default) or before this widget.

Implementation

@widgetFactory
Widget decoration({
  // Common parameters for all decorations
  Color? color,
  DecorationImage? image,
  Gradient? gradient,
  List<BoxShadow>? shadows,
  // BoxDecoration specific parameters
  BoxBorder? border,
  BorderRadiusGeometry? borderRadius,
  BlendMode? backgroundBlendMode,
  BoxShape? boxShape,
  // ShapeDecoration specific parameters
  ShapeBorder? shape,
  // DecoratedBox parameters
  Decoration? decoration,
  DecorationPosition position = DecorationPosition.background,
}) {
  assert(() {
    _debugCheckParameterCombinations(modifier: 'decoration', [
      {
        'border': border,
        'borderRadius': borderRadius,
        'backgroundBlendMode': backgroundBlendMode,
        'boxShape': boxShape,
      },
      {'shape': shape}
    ]);
    return true;
  }());

  if (decoration == null) {
    if (shape != null) {
      decoration = ShapeDecoration(
        shape: shape,
        color: color,
        image: image,
        gradient: gradient,
        shadows: shadows,
      );
    } else {
      decoration = BoxDecoration(
        color: color,
        image: image,
        gradient: gradient,
        boxShadow: shadows,
        border: border,
        borderRadius: borderRadius,
        shape: boxShape ?? BoxShape.rectangle,
        backgroundBlendMode: backgroundBlendMode,
      );
    }
  }

  return FleetDecoratedBox(
    decoration: decoration,
    position: position,
    child: this,
  );
}