Line data Source code
1 : // GENERATED CODE - DO NOT MODIFY BY HAND 2 : 3 : part of 'format.dart'; 4 : 5 : // ************************************************************************** 6 : // SuperEnumGenerator 7 : // ************************************************************************** 8 : 9 : @immutable 10 : abstract class Format extends Equatable { 11 0 : const Format(this._type); 12 : 13 : factory Format.gif() = Gif; 14 : 15 : factory Format.png() = Png; 16 : 17 : factory Format.jpg() = Jpg; 18 : 19 : factory Format.pjpg() = Pjpg; 20 : 21 : factory Format.webp() = Webp; 22 : 23 : factory Format.webplossy() = Webplossy; 24 : 25 : factory Format.webplossless() = Webplossless; 26 : 27 : final _Format _type; 28 : 29 : //ignore: missing_return 30 1 : R when<R>( 31 : {@required R Function(Gif) gif, 32 : @required R Function(Png) png, 33 : @required R Function(Jpg) jpg, 34 : @required R Function(Pjpg) pjpg, 35 : @required R Function(Webp) webp, 36 : @required R Function(Webplossy) webplossy, 37 : @required R Function(Webplossless) webplossless}) { 38 1 : assert(() { 39 : if (gif == null || 40 : png == null || 41 : jpg == null || 42 : pjpg == null || 43 : webp == null || 44 : webplossy == null || 45 : webplossless == null) { 46 : throw 'check for all possible cases'; 47 : } 48 : return true; 49 1 : }()); 50 1 : switch (this._type) { 51 1 : case _Format.Gif: 52 1 : return gif(this as Gif); 53 1 : case _Format.Png: 54 1 : return png(this as Png); 55 1 : case _Format.Jpg: 56 1 : return jpg(this as Jpg); 57 1 : case _Format.Pjpg: 58 1 : return pjpg(this as Pjpg); 59 1 : case _Format.Webp: 60 1 : return webp(this as Webp); 61 1 : case _Format.Webplossy: 62 1 : return webplossy(this as Webplossy); 63 1 : case _Format.Webplossless: 64 1 : return webplossless(this as Webplossless); 65 : } 66 : } 67 : 68 : //ignore: missing_return 69 0 : Future<R> asyncWhen<R>( 70 : {@required FutureOr<R> Function(Gif) gif, 71 : @required FutureOr<R> Function(Png) png, 72 : @required FutureOr<R> Function(Jpg) jpg, 73 : @required FutureOr<R> Function(Pjpg) pjpg, 74 : @required FutureOr<R> Function(Webp) webp, 75 : @required FutureOr<R> Function(Webplossy) webplossy, 76 : @required FutureOr<R> Function(Webplossless) webplossless}) { 77 0 : assert(() { 78 : if (gif == null || 79 : png == null || 80 : jpg == null || 81 : pjpg == null || 82 : webp == null || 83 : webplossy == null || 84 : webplossless == null) { 85 : throw 'check for all possible cases'; 86 : } 87 : return true; 88 0 : }()); 89 0 : switch (this._type) { 90 0 : case _Format.Gif: 91 0 : return gif(this as Gif); 92 0 : case _Format.Png: 93 0 : return png(this as Png); 94 0 : case _Format.Jpg: 95 0 : return jpg(this as Jpg); 96 0 : case _Format.Pjpg: 97 0 : return pjpg(this as Pjpg); 98 0 : case _Format.Webp: 99 0 : return webp(this as Webp); 100 0 : case _Format.Webplossy: 101 0 : return webplossy(this as Webplossy); 102 0 : case _Format.Webplossless: 103 0 : return webplossless(this as Webplossless); 104 : } 105 : } 106 : 107 0 : R whenOrElse<R>( 108 : {R Function(Gif) gif, 109 : R Function(Png) png, 110 : R Function(Jpg) jpg, 111 : R Function(Pjpg) pjpg, 112 : R Function(Webp) webp, 113 : R Function(Webplossy) webplossy, 114 : R Function(Webplossless) webplossless, 115 : @required R Function(Format) orElse}) { 116 0 : assert(() { 117 : if (orElse == null) { 118 : throw 'Missing orElse case'; 119 : } 120 : return true; 121 0 : }()); 122 0 : switch (this._type) { 123 0 : case _Format.Gif: 124 : if (gif == null) break; 125 0 : return gif(this as Gif); 126 0 : case _Format.Png: 127 : if (png == null) break; 128 0 : return png(this as Png); 129 0 : case _Format.Jpg: 130 : if (jpg == null) break; 131 0 : return jpg(this as Jpg); 132 0 : case _Format.Pjpg: 133 : if (pjpg == null) break; 134 0 : return pjpg(this as Pjpg); 135 0 : case _Format.Webp: 136 : if (webp == null) break; 137 0 : return webp(this as Webp); 138 0 : case _Format.Webplossy: 139 : if (webplossy == null) break; 140 0 : return webplossy(this as Webplossy); 141 0 : case _Format.Webplossless: 142 : if (webplossless == null) break; 143 0 : return webplossless(this as Webplossless); 144 : } 145 0 : return orElse(this); 146 : } 147 : 148 0 : Future<R> asyncWhenOrElse<R>( 149 : {FutureOr<R> Function(Gif) gif, 150 : FutureOr<R> Function(Png) png, 151 : FutureOr<R> Function(Jpg) jpg, 152 : FutureOr<R> Function(Pjpg) pjpg, 153 : FutureOr<R> Function(Webp) webp, 154 : FutureOr<R> Function(Webplossy) webplossy, 155 : FutureOr<R> Function(Webplossless) webplossless, 156 : @required FutureOr<R> Function(Format) orElse}) { 157 0 : assert(() { 158 : if (orElse == null) { 159 : throw 'Missing orElse case'; 160 : } 161 : return true; 162 0 : }()); 163 0 : switch (this._type) { 164 0 : case _Format.Gif: 165 : if (gif == null) break; 166 0 : return gif(this as Gif); 167 0 : case _Format.Png: 168 : if (png == null) break; 169 0 : return png(this as Png); 170 0 : case _Format.Jpg: 171 : if (jpg == null) break; 172 0 : return jpg(this as Jpg); 173 0 : case _Format.Pjpg: 174 : if (pjpg == null) break; 175 0 : return pjpg(this as Pjpg); 176 0 : case _Format.Webp: 177 : if (webp == null) break; 178 0 : return webp(this as Webp); 179 0 : case _Format.Webplossy: 180 : if (webplossy == null) break; 181 0 : return webplossy(this as Webplossy); 182 0 : case _Format.Webplossless: 183 : if (webplossless == null) break; 184 0 : return webplossless(this as Webplossless); 185 : } 186 0 : return orElse(this); 187 : } 188 : 189 : //ignore: missing_return 190 0 : Future<void> whenPartial( 191 : {FutureOr<void> Function(Gif) gif, 192 : FutureOr<void> Function(Png) png, 193 : FutureOr<void> Function(Jpg) jpg, 194 : FutureOr<void> Function(Pjpg) pjpg, 195 : FutureOr<void> Function(Webp) webp, 196 : FutureOr<void> Function(Webplossy) webplossy, 197 : FutureOr<void> Function(Webplossless) webplossless}) { 198 0 : assert(() { 199 : if (gif == null && 200 : png == null && 201 : jpg == null && 202 : pjpg == null && 203 : webp == null && 204 : webplossy == null && 205 : webplossless == null) { 206 : throw 'provide at least one branch'; 207 : } 208 : return true; 209 0 : }()); 210 0 : switch (this._type) { 211 0 : case _Format.Gif: 212 : if (gif == null) break; 213 0 : return gif(this as Gif); 214 0 : case _Format.Png: 215 : if (png == null) break; 216 0 : return png(this as Png); 217 0 : case _Format.Jpg: 218 : if (jpg == null) break; 219 0 : return jpg(this as Jpg); 220 0 : case _Format.Pjpg: 221 : if (pjpg == null) break; 222 0 : return pjpg(this as Pjpg); 223 0 : case _Format.Webp: 224 : if (webp == null) break; 225 0 : return webp(this as Webp); 226 0 : case _Format.Webplossy: 227 : if (webplossy == null) break; 228 0 : return webplossy(this as Webplossy); 229 0 : case _Format.Webplossless: 230 : if (webplossless == null) break; 231 0 : return webplossless(this as Webplossless); 232 : } 233 : } 234 : 235 0 : @override 236 : List get props => const []; 237 : } 238 : 239 : @immutable 240 : class Gif extends Format { 241 0 : const Gif._() : super(_Format.Gif); 242 : 243 1 : factory Gif() { 244 : _instance ??= const Gif._(); 245 : return _instance; 246 : } 247 : 248 : static Gif _instance; 249 : } 250 : 251 : @immutable 252 : class Png extends Format { 253 0 : const Png._() : super(_Format.Png); 254 : 255 1 : factory Png() { 256 : _instance ??= const Png._(); 257 : return _instance; 258 : } 259 : 260 : static Png _instance; 261 : } 262 : 263 : @immutable 264 : class Jpg extends Format { 265 0 : const Jpg._() : super(_Format.Jpg); 266 : 267 1 : factory Jpg() { 268 : _instance ??= const Jpg._(); 269 : return _instance; 270 : } 271 : 272 : static Jpg _instance; 273 : } 274 : 275 : @immutable 276 : class Pjpg extends Format { 277 0 : const Pjpg._() : super(_Format.Pjpg); 278 : 279 1 : factory Pjpg() { 280 : _instance ??= const Pjpg._(); 281 : return _instance; 282 : } 283 : 284 : static Pjpg _instance; 285 : } 286 : 287 : @immutable 288 : class Webp extends Format { 289 0 : const Webp._() : super(_Format.Webp); 290 : 291 1 : factory Webp() { 292 : _instance ??= const Webp._(); 293 : return _instance; 294 : } 295 : 296 : static Webp _instance; 297 : } 298 : 299 : @immutable 300 : class Webplossy extends Format { 301 0 : const Webplossy._() : super(_Format.Webplossy); 302 : 303 1 : factory Webplossy() { 304 : _instance ??= const Webplossy._(); 305 : return _instance; 306 : } 307 : 308 : static Webplossy _instance; 309 : } 310 : 311 : @immutable 312 : class Webplossless extends Format { 313 0 : const Webplossless._() : super(_Format.Webplossless); 314 : 315 1 : factory Webplossless() { 316 : _instance ??= const Webplossless._(); 317 : return _instance; 318 : } 319 : 320 : static Webplossless _instance; 321 : }