CustomConfig constructor

CustomConfig({
  1. List<Color>? colors,
  2. List<List<Color>>? gradients,
  3. Alignment? gradientBegin,
  4. Alignment? gradientEnd,
  5. required List<int>? durations,
  6. required List<double>? heightPercentages,
  7. MaskFilter? blur,
})

Implementation

CustomConfig({
  this.colors,
  this.gradients,
  this.gradientBegin,
  this.gradientEnd,
  required this.durations,
  required this.heightPercentages,
  this.blur,
})  : assert(() {
        if (colors == null && gradients == null) {
          Config.throwNullError('custom', 'colors` or `gradients');
        }
        return true;
      }()),
      assert(() {
        if (gradients == null &&
            (gradientBegin != null || gradientEnd != null)) {
          throw FlutterError(
              'You set a gradient direction but forgot setting `gradients`.');
        }
        return true;
      }()),
      assert(() {
        if (durations == null) {
          Config.throwNullError('custom', 'durations');
        }
        return true;
      }()),
      assert(() {
        if (heightPercentages == null) {
          Config.throwNullError('custom', 'heightPercentages');
        }
        return true;
      }()),
      assert(() {
        if (colors != null &&
            durations != null &&
            heightPercentages != null) {
          if (colors.length != durations.length ||
              colors.length != heightPercentages.length) {
            throw FlutterError(
                'Length of `colors`, `durations` and `heightPercentages` must be equal.');
          }
        }
        return true;
      }()),
      assert(colors == null || gradients == null,
          'Cannot provide both colors and gradients.'),
      super(colorMode: ColorMode.custom);