Navaron Bracke

convert barcode type to enhanced enum

1 -/// Barcode value type constants 1 +/// Barcode value type constants.
2 enum BarcodeType { 2 enum BarcodeType {
3 - /// Barcode value type unknown, which indicates the current version of SDK cannot recognize the structure of the barcode. Developers can inspect the raw value instead.  
4 - ///  
5 - /// Constant Value: 0  
6 - unknown, 3 + /// An unknown barcode type.
  4 + unknown(0),
7 5
8 /// Barcode value type constant for contact information. 6 /// Barcode value type constant for contact information.
9 - ///  
10 - /// Constant Value: 1  
11 - contactInfo, 7 + contactInfo(1),
12 8
13 /// Barcode value type constant for email message details. 9 /// Barcode value type constant for email message details.
14 - ///  
15 - /// Constant Value: 2  
16 - email, 10 + email(2),
17 11
18 /// Barcode value type constant for ISBNs. 12 /// Barcode value type constant for ISBNs.
19 - ///  
20 - /// Constant Value: 3  
21 - isbn, 13 + isbn(3),
22 14
23 /// Barcode value type constant for phone numbers. 15 /// Barcode value type constant for phone numbers.
24 - ///  
25 - /// Constant Value: 4  
26 - phone, 16 + phone(4),
27 17
28 /// Barcode value type constant for product codes. 18 /// Barcode value type constant for product codes.
29 - ///  
30 - /// Constant Value: 5  
31 - product, 19 + product(5),
32 20
33 /// Barcode value type constant for SMS details. 21 /// Barcode value type constant for SMS details.
34 - ///  
35 - /// Constant Value: 6  
36 - sms, 22 + sms(6),
37 23
38 /// Barcode value type constant for plain text. 24 /// Barcode value type constant for plain text.
39 - ///  
40 - ///Constant Value: 7  
41 - text, 25 + text(7),
42 26
43 - /// Barcode value type constant for URLs/bookmarks.  
44 - ///  
45 - /// Constant Value: 8  
46 - url, 27 + /// Barcode value type constant for URLs or bookmarks.
  28 + url(8),
47 29
48 /// Barcode value type constant for WiFi access point details. 30 /// Barcode value type constant for WiFi access point details.
49 - ///  
50 - /// Constant Value: 9  
51 - wifi, 31 + wifi(9),
52 32
53 /// Barcode value type constant for geographic coordinates. 33 /// Barcode value type constant for geographic coordinates.
54 - ///  
55 - /// Constant Value: 10  
56 - geo, 34 + geo(10),
57 35
58 /// Barcode value type constant for calendar events. 36 /// Barcode value type constant for calendar events.
59 - ///  
60 - /// Constant Value: 11  
61 - calendarEvent, 37 + calendarEvent(11),
62 38
63 - /// Barcode value type constant for driver's license data.  
64 - ///  
65 - /// Constant Value: 12  
66 - driverLicense, 39 + /// Barcode value type constant for driver license data.
  40 + driverLicense(12);
  41 +
  42 + const BarcodeType(this.rawValue);
  43 +
  44 + factory BarcodeType.fromRawValue(int value) {
  45 + switch (value) {
  46 + case 1:
  47 + return BarcodeType.contactInfo;
  48 + case 2:
  49 + return BarcodeType.email;
  50 + case 3:
  51 + return BarcodeType.isbn;
  52 + case 4:
  53 + return BarcodeType.phone;
  54 + case 5:
  55 + return BarcodeType.product;
  56 + case 6:
  57 + return BarcodeType.sms;
  58 + case 7:
  59 + return BarcodeType.text;
  60 + case 8:
  61 + return BarcodeType.url;
  62 + case 9:
  63 + return BarcodeType.wifi;
  64 + case 10:
  65 + return BarcodeType.geo;
  66 + case 11:
  67 + return BarcodeType.calendarEvent;
  68 + case 12:
  69 + return BarcodeType.driverLicense;
  70 + case 0:
  71 + default:
  72 + return BarcodeType.unknown;
  73 + }
  74 + }
  75 +
  76 + /// The raw barcode type value.
  77 + final int rawValue;
67 } 78 }