Navaron Bracke

convert encryption type to enhanced enum

1 /// Wifi encryption type constants. 1 /// Wifi encryption type constants.
2 enum EncryptionType { 2 enum EncryptionType {
3 /// Unknown encryption type. 3 /// Unknown encryption type.
4 - ///  
5 - /// Constant Value: 0  
6 - none, 4 + none(0),
7 5
8 /// Not encrypted. 6 /// Not encrypted.
9 - ///  
10 - /// Constant Value: 1  
11 - open, 7 + open(1),
12 8
13 /// WPA level encryption. 9 /// WPA level encryption.
14 - ///  
15 - /// Constant Value: 2  
16 - wpa, 10 + wpa(2),
17 11
18 /// WEP level encryption. 12 /// WEP level encryption.
19 - ///  
20 - /// Constant Value: 3  
21 - wep, 13 + wep(3);
  14 +
  15 + const EncryptionType(this.rawValue);
  16 +
  17 + factory EncryptionType.fromRawValue(int value) {
  18 + switch (value) {
  19 + case 1:
  20 + return EncryptionType.open;
  21 + case 2:
  22 + return EncryptionType.wpa;
  23 + case 3:
  24 + return EncryptionType.wep;
  25 + case 0:
  26 + default:
  27 + return EncryptionType.none;
  28 + }
  29 + }
  30 +
  31 + /// The raw value for the encryption type.
  32 + final int rawValue;
22 } 33 }