Line data Source code
1 : // GENERATED CODE - DO NOT MODIFY BY HAND 2 : 3 : part of 'fit.dart'; 4 : 5 : // ************************************************************************** 6 : // SuperEnumGenerator 7 : // ************************************************************************** 8 : 9 : @immutable 10 : abstract class Fit extends Equatable { 11 0 : const Fit(this._type); 12 : 13 : factory Fit.bounds() = Bounds; 14 : 15 : factory Fit.crop() = Crop; 16 : 17 : final _Fit _type; 18 : 19 : //ignore: missing_return 20 1 : R when<R>( 21 : {@required R Function(Bounds) bounds, @required R Function(Crop) crop}) { 22 1 : assert(() { 23 : if (bounds == null || crop == null) { 24 : throw 'check for all possible cases'; 25 : } 26 : return true; 27 1 : }()); 28 1 : switch (this._type) { 29 1 : case _Fit.Bounds: 30 1 : return bounds(this as Bounds); 31 1 : case _Fit.Crop: 32 1 : return crop(this as Crop); 33 : } 34 : } 35 : 36 : //ignore: missing_return 37 0 : Future<R> asyncWhen<R>( 38 : {@required FutureOr<R> Function(Bounds) bounds, 39 : @required FutureOr<R> Function(Crop) crop}) { 40 0 : assert(() { 41 : if (bounds == null || crop == null) { 42 : throw 'check for all possible cases'; 43 : } 44 : return true; 45 0 : }()); 46 0 : switch (this._type) { 47 0 : case _Fit.Bounds: 48 0 : return bounds(this as Bounds); 49 0 : case _Fit.Crop: 50 0 : return crop(this as Crop); 51 : } 52 : } 53 : 54 0 : R whenOrElse<R>( 55 : {R Function(Bounds) bounds, 56 : R Function(Crop) crop, 57 : @required R Function(Fit) orElse}) { 58 0 : assert(() { 59 : if (orElse == null) { 60 : throw 'Missing orElse case'; 61 : } 62 : return true; 63 0 : }()); 64 0 : switch (this._type) { 65 0 : case _Fit.Bounds: 66 : if (bounds == null) break; 67 0 : return bounds(this as Bounds); 68 0 : case _Fit.Crop: 69 : if (crop == null) break; 70 0 : return crop(this as Crop); 71 : } 72 0 : return orElse(this); 73 : } 74 : 75 0 : Future<R> asyncWhenOrElse<R>( 76 : {FutureOr<R> Function(Bounds) bounds, 77 : FutureOr<R> Function(Crop) crop, 78 : @required FutureOr<R> Function(Fit) orElse}) { 79 0 : assert(() { 80 : if (orElse == null) { 81 : throw 'Missing orElse case'; 82 : } 83 : return true; 84 0 : }()); 85 0 : switch (this._type) { 86 0 : case _Fit.Bounds: 87 : if (bounds == null) break; 88 0 : return bounds(this as Bounds); 89 0 : case _Fit.Crop: 90 : if (crop == null) break; 91 0 : return crop(this as Crop); 92 : } 93 0 : return orElse(this); 94 : } 95 : 96 : //ignore: missing_return 97 0 : Future<void> whenPartial( 98 : {FutureOr<void> Function(Bounds) bounds, 99 : FutureOr<void> Function(Crop) crop}) { 100 0 : assert(() { 101 : if (bounds == null && crop == null) { 102 : throw 'provide at least one branch'; 103 : } 104 : return true; 105 0 : }()); 106 0 : switch (this._type) { 107 0 : case _Fit.Bounds: 108 : if (bounds == null) break; 109 0 : return bounds(this as Bounds); 110 0 : case _Fit.Crop: 111 : if (crop == null) break; 112 0 : return crop(this as Crop); 113 : } 114 : } 115 : 116 0 : @override 117 : List get props => const []; 118 : } 119 : 120 : @immutable 121 : class Bounds extends Fit { 122 0 : const Bounds._() : super(_Fit.Bounds); 123 : 124 1 : factory Bounds() { 125 : _instance ??= const Bounds._(); 126 : return _instance; 127 : } 128 : 129 : static Bounds _instance; 130 : } 131 : 132 : @immutable 133 : class Crop extends Fit { 134 0 : const Crop._() : super(_Fit.Crop); 135 : 136 1 : factory Crop() { 137 : _instance ??= const Crop._(); 138 : return _instance; 139 : } 140 : 141 : static Crop _instance; 142 : }