RainbowContainer constructor

RainbowContainer({
  1. Key? key,
  2. Widget? child,
  3. AlignmentGeometry? alignment,
  4. EdgeInsetsGeometry? padding,
  5. Decoration? decoration,
  6. Decoration? foregroundDecoration,
  7. double? width,
  8. double? height,
  9. BoxConstraints? constraints,
  10. EdgeInsetsGeometry? margin,
  11. Matrix4? transform,
  12. AlignmentGeometry? transformAlignment,
  13. Clip clipBehavior = Clip.none,
})

A Container which will change colors randomly each time the build method is called.

RainbowContainer(
  child: Text('Hello world'),
);

Implementation

RainbowContainer({
  Key? key,
  Widget? child,
  AlignmentGeometry? alignment,
  EdgeInsetsGeometry? padding,
  Decoration? decoration,
  Decoration? foregroundDecoration,
  double? width,
  double? height,
  BoxConstraints? constraints,
  EdgeInsetsGeometry? margin,
  Matrix4? transform,
  AlignmentGeometry? transformAlignment,
  Clip clipBehavior = Clip.none,
}) : super(
        key: key,
        child: child,
        color: decoration is BoxDecoration ? null : _randomColor,
        alignment: alignment,
        padding: padding,
        decoration: decoration is BoxDecoration
            ? decoration.copyWith(color: _randomColor)
            : decoration,
        foregroundDecoration: foregroundDecoration,
        width: width,
        height: height,
        constraints: constraints,
        margin: margin,
        transform: transform,
        transformAlignment: transformAlignment,
        clipBehavior: clipBehavior,
      );