asNill property

Gradient asNill

Gradient get asNill => nillify( /* this. */ runtimeType);

Returns an empty, transparent Gradient of type matching runtimeType if one is available. If this gradient's type is not pre-mapped to an empty, transparent "nill" gradient, this is copied with a number of pre-set "nill"-style properties, such as transparent colors, 0 radius, stops [1.0, 1.0], etc.

Gradient.copyWith itself falls back to returning a new RadialGradient if type cannot be matched.

Used as:

final radialGradient = RadialGradient(. . .);
final emptyRadialGradient = radialGradient.asNill;

Implementation

Gradient get asNill =>
    nillify(runtimeType) ??
    copyWith(
      colors: [Colors.transparent, Colors.transparent],
      stops: [1.0, 1.0],
      tileMode: TileMode.clamp,
      begin: Alignment.center,
      end: Alignment.center,
      center: Alignment.center,
      startAngle: 0.0,
      endAngle: 0.0,
      radius: 0.0,
      focal: Alignment.center,
      focalRadius: 0.0,
    );