Navaron Bracke

move WiFi to its own file

@@ -18,3 +18,4 @@ export 'src/objects/calendar_event.dart'; @@ -18,3 +18,4 @@ export 'src/objects/calendar_event.dart';
18 export 'src/objects/driver_license.dart'; 18 export 'src/objects/driver_license.dart';
19 export 'src/objects/email.dart'; 19 export 'src/objects/email.dart';
20 export 'src/objects/mobile_scanner_arguments.dart'; 20 export 'src/objects/mobile_scanner_arguments.dart';
  21 +export 'src/objects/wifi.dart';
@@ -5,11 +5,11 @@ import 'package:mobile_scanner/src/barcode_utility.dart'; @@ -5,11 +5,11 @@ import 'package:mobile_scanner/src/barcode_utility.dart';
5 import 'package:mobile_scanner/src/enums/address_type.dart'; 5 import 'package:mobile_scanner/src/enums/address_type.dart';
6 import 'package:mobile_scanner/src/enums/barcode_format.dart'; 6 import 'package:mobile_scanner/src/enums/barcode_format.dart';
7 import 'package:mobile_scanner/src/enums/barcode_type.dart'; 7 import 'package:mobile_scanner/src/enums/barcode_type.dart';
8 -import 'package:mobile_scanner/src/enums/encryption_type.dart';  
9 import 'package:mobile_scanner/src/enums/phone_type.dart'; 8 import 'package:mobile_scanner/src/enums/phone_type.dart';
10 import 'package:mobile_scanner/src/objects/calendar_event.dart'; 9 import 'package:mobile_scanner/src/objects/calendar_event.dart';
11 import 'package:mobile_scanner/src/objects/driver_license.dart'; 10 import 'package:mobile_scanner/src/objects/driver_license.dart';
12 import 'package:mobile_scanner/src/objects/email.dart'; 11 import 'package:mobile_scanner/src/objects/email.dart';
  12 +import 'package:mobile_scanner/src/objects/wifi.dart';
13 13
14 /// Represents a single recognized barcode and its value. 14 /// Represents a single recognized barcode and its value.
15 class Barcode { 15 class Barcode {
@@ -309,27 +309,3 @@ class UrlBookmark { @@ -309,27 +309,3 @@ class UrlBookmark {
309 : title = data['title'] as String?, 309 : title = data['title'] as String?,
310 url = data['url'] as String?; 310 url = data['url'] as String?;
311 } 311 }
312 -  
313 -/// A wifi network parameters from a 'WIFI:' or similar QRCode type.  
314 -class WiFi {  
315 - /// Gets the encryption type of the WIFI.  
316 - ///  
317 - /// See all [EncryptionType].  
318 - final EncryptionType encryptionType;  
319 -  
320 - /// Gets the ssid of the WIFI.  
321 - ///  
322 - /// Returns null if not available.  
323 - final String? ssid;  
324 -  
325 - /// Gets the password of the WIFI.  
326 - ///  
327 - /// Returns null if not available.  
328 - final String? password;  
329 -  
330 - /// Create a [WiFi] from native data.  
331 - WiFi.fromNative(Map data)  
332 - : encryptionType = EncryptionType.values[data['encryptionType'] as int],  
333 - ssid = data['ssid'] as String?,  
334 - password = data['password'] as String?;  
335 -}  
  1 +import 'package:mobile_scanner/src/enums/barcode_type.dart';
  2 +import 'package:mobile_scanner/src/enums/encryption_type.dart';
  3 +
  4 +/// Wireless network information from [BarcodeType.wifi] barcodes.
  5 +class WiFi {
  6 + /// Construct a new [WiFi] instance.
  7 + const WiFi({
  8 + this.encryptionType = EncryptionType.none,
  9 + this.ssid,
  10 + this.password,
  11 + });
  12 +
  13 + /// Construct a new [WiFi] instance from the given [data].
  14 + factory WiFi.fromNative(Map<Object?, Object?> data) {
  15 + return WiFi(
  16 + encryptionType: EncryptionType.fromRawValue(
  17 + data['encryptionType'] as int? ?? 0,
  18 + ),
  19 + ssid: data['ssid'] as String?,
  20 + password: data['password'] as String?,
  21 + );
  22 + }
  23 +
  24 + /// The encryption type of the wireless network.
  25 + final EncryptionType encryptionType;
  26 +
  27 + /// The ssid of the wireless network.
  28 + final String? ssid;
  29 +
  30 + /// The password of the wireless network.
  31 + final String? password;
  32 +}