ImageStyle constructor

const ImageStyle({
  1. BoxFit fit = BoxFit.contain,
  2. double width = double.infinity,
  3. double height = double.infinity,
  4. Color? color,
  5. BlendMode? colorBlendMode,
  6. AlignmentGeometry? alignment,
})

Creates an ImageStyle configuration.

The fit parameter defaults to BoxFit.contain, and width and height default to double.infinity. Note that BoxFit.scaleDown and BoxFit.none are not supported and will cause an assertion error.

Example:

ImageStyle(
  fit: BoxFit.cover,
  width: 300,
  height: 200,
  color: Colors.blue,
  colorBlendMode: BlendMode.srcIn,
)

Implementation

const ImageStyle(
    {this.fit = BoxFit.contain,
    this.width = double.infinity,
    this.height = double.infinity,
    this.color,
    this.colorBlendMode,
    this.alignment})
    : assert(fit != BoxFit.scaleDown,
          "Fit cannot be scaleDown. Use contain instead."),
      assert(fit != BoxFit.none, "Fit cannot be none. Use contain instead.");