flutter update fixes
Serhii committed
Oct 24, 2022 at 14:47 UTC
a6d5a145b9a7edd5e112c16891232355430f7d0c
1 file changed
+106
-258
cw_core/lib/crypto_currency.dart
+106
-258
@@ -137,272 +137,120 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
137
static const uni = CryptoCurrency(title: 'UNI', iconPath: 'assets/images/uni_icon.png', tag: 'ETH', raw: 61);
138
static const stx = CryptoCurrency(title: 'STX', iconPath: 'assets/images/stx_icon.png', raw: 62);
139
140
+ static const mapFromInt = {
141
+ 0: CryptoCurrency.xmr,
142
+ 1: CryptoCurrency.ada,
143
+ 2: CryptoCurrency.bch,
144
+ 3: CryptoCurrency.bnb,
145
+ 4: CryptoCurrency.btc,
146
+ 5: CryptoCurrency.dai,
147
+ 6: CryptoCurrency.dash,
148
+ 7: CryptoCurrency.eos,
149
+ 8: CryptoCurrency.eth,
150
+ 9: CryptoCurrency.ltc,
151
+ 10: CryptoCurrency.nano,
152
+ 11: CryptoCurrency.trx,
153
+ 12: CryptoCurrency.usdt,
154
+ 13: CryptoCurrency.usdterc20,
155
+ 14: CryptoCurrency.xlm,
156
+ 15: CryptoCurrency.xrp,
157
+ 16: CryptoCurrency.xhv,
158
+ 17: CryptoCurrency.xag,
159
+ 18: CryptoCurrency.xau,
160
+ 19: CryptoCurrency.xaud,
161
+ 20: CryptoCurrency.xbtc,
162
+ 21: CryptoCurrency.xcad,
163
+ 22: CryptoCurrency.xchf,
164
+ 23: CryptoCurrency.xcny,
165
+ 24: CryptoCurrency.xeur,
166
+ 25: CryptoCurrency.xgbp,
167
+ 26: CryptoCurrency.xjpy,
168
+ 27: CryptoCurrency.xnok,
169
+ 28: CryptoCurrency.xnzd,
170
+ 29: CryptoCurrency.xusd,
171
+ 30: CryptoCurrency.ape,
172
+ 31: CryptoCurrency.avaxc,
173
+ 32: CryptoCurrency.btt,
174
+ 33: CryptoCurrency.bttbsc,
175
+ 34: CryptoCurrency.doge,
176
+ 35: CryptoCurrency.firo,
177
+ 36: CryptoCurrency.usdttrc20,
178
+ 37: CryptoCurrency.hbar,
179
+ 38: CryptoCurrency.sc,
180
+ 39: CryptoCurrency.sol,
181
+ 40: CryptoCurrency.usdc,
182
+ 41: CryptoCurrency.usdcsol,
183
+ 42: CryptoCurrency.zaddr,
184
+ 43: CryptoCurrency.zec,
185
+ 44: CryptoCurrency.zen,
186
+ 45: CryptoCurrency.xvg
187
+ };
188
189
+ static const mapFromString = {
190
+ 'xmr': CryptoCurrency.xmr,
191
+ 'ada': CryptoCurrency.ada,
192
+ 'bch': CryptoCurrency.bch,
193
+ 'bnb': CryptoCurrency.bnb,
194
+ 'btc': CryptoCurrency.btc,
195
+ 'dai': CryptoCurrency.dai,
196
+ 'dash': CryptoCurrency.dash,
197
+ 'eos': CryptoCurrency.eos,
198
+ 'eth': CryptoCurrency.eth,
199
+ 'ltc': CryptoCurrency.ltc,
200
+ 'nano': CryptoCurrency.nano,
201
+ 'trx': CryptoCurrency.trx,
202
+ 'usdt': CryptoCurrency.usdt,
203
+ 'usdterc20': CryptoCurrency.usdterc20,
204
+ 'xlm': CryptoCurrency.xlm,
205
+ 'xrp': CryptoCurrency.xrp,
206
+ 'xhv': CryptoCurrency.xhv,
207
+ 'xag': CryptoCurrency.xag,
208
+ 'xau': CryptoCurrency.xau,
209
+ 'xaud': CryptoCurrency.xaud,
210
+ 'xbtc': CryptoCurrency.xbtc,
211
+ 'xcad': CryptoCurrency.xcad,
212
+ 'xchf': CryptoCurrency.xchf,
213
+ 'xcny': CryptoCurrency.xcny,
214
+ 'xeur': CryptoCurrency.xeur,
215
+ 'xgbp': CryptoCurrency.xgbp,
216
+ 'xjpy': CryptoCurrency.xjpy,
217
+ 'xnok': CryptoCurrency.xnok,
218
+ 'xnzd': CryptoCurrency.xnzd,
219
+ 'xusd': CryptoCurrency.xusd,
220
+ 'ape': CryptoCurrency.ape,
221
+ 'avaxc': CryptoCurrency.avaxc,
222
+ 'btt': CryptoCurrency.btt,
223
+ 'bttbsc': CryptoCurrency.bttbsc,
224
+ 'doge': CryptoCurrency.doge,
225
+ 'firo': CryptoCurrency.firo,
226
+ 'usdttrc20': CryptoCurrency.usdttrc20,
227
+ 'hbar': CryptoCurrency.hbar,
228
+ 'sc': CryptoCurrency.sc,
229
+ 'sol': CryptoCurrency.sol,
230
+ 'usdc': CryptoCurrency.usdc,
231
+ 'usdcsol': CryptoCurrency.usdcsol,
232
+ 'zaddr': CryptoCurrency.zaddr,
233
+ 'zec': CryptoCurrency.zec,
234
+ 'zen': CryptoCurrency.zen,
235
+ 'xvg': CryptoCurrency.xvg
236
+ };
237
238
static CryptoCurrency deserialize({required int raw}) {
143
- switch (raw) {
144
- case 0:
145
- return CryptoCurrency.xmr;
146
- case 1:
147
- return CryptoCurrency.ada;
148
- case 2:
149
- return CryptoCurrency.bch;
150
- case 3:
151
- return CryptoCurrency.bnb;
152
- case 4:
153
- return CryptoCurrency.btc;
154
- case 5:
155
- return CryptoCurrency.dai;
156
- case 6:
157
- return CryptoCurrency.dash;
158
- case 7:
159
- return CryptoCurrency.eos;
160
- case 8:
161
- return CryptoCurrency.eth;
162
- case 9:
163
- return CryptoCurrency.ltc;
164
- case 10:
165
- return CryptoCurrency.nano;
166
- case 11:
167
- return CryptoCurrency.trx;
168
- case 12:
169
- return CryptoCurrency.usdt;
170
- case 13:
171
- return CryptoCurrency.usdterc20;
172
- case 14:
173
- return CryptoCurrency.xlm;
174
- case 15:
175
- return CryptoCurrency.xrp;
176
- case 16:
177
- return CryptoCurrency.xhv;
178
- case 17:
179
- return CryptoCurrency.xag;
180
- case 18:
181
- return CryptoCurrency.xau;
182
- case 19:
183
- return CryptoCurrency.xaud;
184
- case 20:
185
- return CryptoCurrency.xbtc;
186
- case 21:
187
- return CryptoCurrency.xcad;
188
- case 22:
189
- return CryptoCurrency.xchf;
190
- case 23:
191
- return CryptoCurrency.xcny;
192
- case 24:
193
- return CryptoCurrency.xeur;
194
- case 25:
195
- return CryptoCurrency.xgbp;
196
- case 26:
197
- return CryptoCurrency.xjpy;
198
- case 27:
199
- return CryptoCurrency.xnok;
200
- case 28:
201
- return CryptoCurrency.xnzd;
202
- case 29:
203
- return CryptoCurrency.xusd;
204
- case 30:
205
- return CryptoCurrency.ape;
206
- case 31:
207
- return CryptoCurrency.avaxc;
208
- case 32:
209
- return CryptoCurrency.btt;
210
- case 33:
211
- return CryptoCurrency.bttbsc;
212
- case 34:
213
- return CryptoCurrency.doge;
214
- case 35:
215
- return CryptoCurrency.firo;
216
- case 36:
217
- return CryptoCurrency.usdttrc20;
218
- case 37:
219
- return CryptoCurrency.hbar;
220
- case 38:
221
- return CryptoCurrency.sc;
222
- case 39:
223
- return CryptoCurrency.sol;
224
- case 40:
225
- return CryptoCurrency.usdc;
226
- case 41:
227
- return CryptoCurrency.usdcsol;
228
- case 42:
229
- return CryptoCurrency.zaddr;
230
- case 43:
231
- return CryptoCurrency.zec;
232
- case 44:
233
- return CryptoCurrency.zen;
234
- case 45:
235
- return CryptoCurrency.xvg;
236
- case 46:
237
- return CryptoCurrency.usdcpoly;
238
- case 47:
239
- return CryptoCurrency.dcr;
240
- case 48:
241
- return CryptoCurrency.husd;
242
- case 49:
243
- return CryptoCurrency.kmd;
244
- case 50:
245
- return CryptoCurrency.mana;
246
- case 51:
247
- return CryptoCurrency.maticpoly;
248
- case 52:
249
- return CryptoCurrency.matic;
250
- case 53:
251
- return CryptoCurrency.mkr;
252
- case 54:
253
- return CryptoCurrency.near;
254
- case 55:
255
- return CryptoCurrency.oxt;
256
- case 56:
257
- return CryptoCurrency.paxg;
258
- case 57:
259
- return CryptoCurrency.pivx;
260
- case 58:
261
- return CryptoCurrency.rune;
262
- case 59:
263
- return CryptoCurrency.rvn;
264
- case 60:
265
- return CryptoCurrency.scrt;
266
- case 61:
267
- return CryptoCurrency.uni;
268
- case 62:
269
- return CryptoCurrency.stx;
270
- default:
271
- throw Exception('Unexpected token: $raw for CryptoCurrency deserialize');
239
+
240
+ if (CryptoCurrency.mapFromInt[raw] == null) {
241
+ final s = 'Unexpected token: $raw for CryptoCurrency deserialize';
242
+ throw ArgumentError.value(raw, 'raw', s);
243
}
244
+ return CryptoCurrency.mapFromInt[raw]!;
245
}
246
247
static CryptoCurrency fromString(String raw) {
276
- switch (raw.toLowerCase()) {
277
- case 'xmr':
278
- return CryptoCurrency.xmr;
279
- case 'ada':
280
- return CryptoCurrency.ada;
281
- case 'bch':
282
- return CryptoCurrency.bch;
283
- case 'bnbmainnet':
284
- return CryptoCurrency.bnb;
285
- case 'btc':
286
- return CryptoCurrency.btc;
287
- case 'dai':
288
- return CryptoCurrency.dai;
289
- case 'dash':
290
- return CryptoCurrency.dash;
291
- case 'eos':
292
- return CryptoCurrency.eos;
293
- case 'eth':
294
- return CryptoCurrency.eth;
295
- case 'ltc':
296
- return CryptoCurrency.ltc;
297
- case 'nano':
298
- return CryptoCurrency.nano;
299
- case 'trx':
300
- return CryptoCurrency.trx;
301
- case 'usdc':
302
- return CryptoCurrency.usdc;
303
- case 'usdterc20':
304
- return CryptoCurrency.usdterc20;
305
- case 'xlm':
306
- return CryptoCurrency.xlm;
307
- case 'xrp':
308
- return CryptoCurrency.xrp;
309
- case 'xhv':
310
- return CryptoCurrency.xhv;
311
- case 'xag':
312
- return CryptoCurrency.xag;
313
- case 'xau':
314
- return CryptoCurrency.xau;
315
- case 'xaud':
316
- return CryptoCurrency.xaud;
317
- case 'xbtc':
318
- return CryptoCurrency.xbtc;
319
- case 'xcad':
320
- return CryptoCurrency.xcad;
321
- case 'xchf':
322
- return CryptoCurrency.xchf;
323
- case 'xcny':
324
- return CryptoCurrency.xcny;
325
- case 'xeur':
326
- return CryptoCurrency.xeur;
327
- case 'xgbp':
328
- return CryptoCurrency.xgbp;
329
- case 'xjpy':
330
- return CryptoCurrency.xjpy;
331
- case 'xnok':
332
- return CryptoCurrency.xnok;
333
- case 'xnzd':
334
- return CryptoCurrency.xnzd;
335
- case 'xusd':
336
- return CryptoCurrency.xusd;
337
- case 'ape':
338
- return CryptoCurrency.ape;
339
- case 'avax':
340
- return CryptoCurrency.avaxc;
341
- case 'btt':
342
- return CryptoCurrency.btt;
343
- case 'bttbsc':
344
- return CryptoCurrency.bttbsc;
345
- case 'doge':
346
- return CryptoCurrency.doge;
347
- case 'firo':
348
- return CryptoCurrency.firo;
349
- case 'usdttrc20':
350
- return CryptoCurrency.usdttrc20;
351
- case 'hbar':
352
- return CryptoCurrency.hbar;
353
- case 'sc':
354
- return CryptoCurrency.sc;
355
- case 'sol':
356
- return CryptoCurrency.sol;
357
- case 'usdt':
358
- return CryptoCurrency.usdt;
359
- case 'usdcsol':
360
- return CryptoCurrency.usdcsol;
361
- case 'zaddr':
362
- return CryptoCurrency.zaddr;
363
- case 'zec':
364
- return CryptoCurrency.zec;
365
- case 'zen':
366
- return CryptoCurrency.zen;
367
- case 'xvg':
368
- return CryptoCurrency.xvg;
369
- case 'usdcpoly':
370
- return CryptoCurrency.usdcpoly;
371
- case 'dcr':
372
- return CryptoCurrency.dcr;
373
- case 'husd':
374
- return CryptoCurrency.husd;
375
- case 'kmd':
376
- return CryptoCurrency.kmd;
377
- case 'mana':
378
- return CryptoCurrency.mana;
379
- case 'maticpoly':
380
- return CryptoCurrency.maticpoly;
381
- case 'matic':
382
- return CryptoCurrency.matic;
383
- case 'mkr':
384
- return CryptoCurrency.mkr;
385
- case 'near':
386
- return CryptoCurrency.near;
387
- case 'oxt':
388
- return CryptoCurrency.oxt;
389
- case 'paxg':
390
- return CryptoCurrency.paxg;
391
- case 'pivx':
392
- return CryptoCurrency.pivx;
393
- case 'rune':
394
- return CryptoCurrency.rune;
395
- case 'rvn':
396
- return CryptoCurrency.rvn;
397
- case 'scrt':
398
- return CryptoCurrency.scrt;
399
- case 'uni':
400
- return CryptoCurrency.uni;
401
- case 'stx':
402
- return CryptoCurrency.stx;
403
- default:
404
- throw Exception('Unexpected token: $raw for CryptoCurrency fromString');
248
+
249
+ if (CryptoCurrency.mapFromString[raw.toLowerCase()] == null) {
250
+ final s = 'Unexpected token: $raw for CryptoCurrency fromString';
251
+ throw ArgumentError.value(raw, 'raw', s);
252
}
253
+ return CryptoCurrency.mapFromString[raw.toLowerCase()]!;
254
}
255
256
@override