diff --git a/CHANGELOG.md b/CHANGELOG.md index ff9d4a1f4..412a20625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 5.2.3 + +Deprecations: +* The `EncryptionType.none` constant has been deprecated, as its name was misleading. Use `EncryptionType.unknown` instead. + +Bugs fixed: +* Fixed `EncryptionType` throwing on invalid `SAE` encryption type. +* [web] Removed the `controls` attribute on the video preview. + +Improvements: +* All enum types for barcode data (i.e. Wifi type or email type) now return `unknown` for unrecognized values. + ## 5.2.2 Improvements: diff --git a/ios/mobile_scanner.podspec b/ios/mobile_scanner.podspec index 61dd8e6b1..cff74e2bc 100644 --- a/ios/mobile_scanner.podspec +++ b/ios/mobile_scanner.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'mobile_scanner' - s.version = '5.2.2' + s.version = '5.2.3' s.summary = 'An universal scanner for Flutter based on MLKit.' s.description = <<-DESC An universal scanner for Flutter based on MLKit. diff --git a/lib/src/enums/address_type.dart b/lib/src/enums/address_type.dart index 2f8de5ccf..e5266b6cf 100644 --- a/lib/src/enums/address_type.dart +++ b/lib/src/enums/address_type.dart @@ -20,7 +20,7 @@ enum AddressType { case 2: return AddressType.home; default: - throw ArgumentError.value(value, 'value', 'Invalid raw value.'); + return AddressType.unknown; } } diff --git a/lib/src/enums/barcode_type.dart b/lib/src/enums/barcode_type.dart index 76fce7f99..559561e8f 100644 --- a/lib/src/enums/barcode_type.dart +++ b/lib/src/enums/barcode_type.dart @@ -70,7 +70,7 @@ enum BarcodeType { case 12: return BarcodeType.driverLicense; default: - throw ArgumentError.value(value, 'value', 'Invalid raw value.'); + return BarcodeType.unknown; } } diff --git a/lib/src/enums/email_type.dart b/lib/src/enums/email_type.dart index b753cd8f1..f9a6be1c5 100644 --- a/lib/src/enums/email_type.dart +++ b/lib/src/enums/email_type.dart @@ -20,7 +20,7 @@ enum EmailType { case 2: return EmailType.home; default: - throw ArgumentError.value(value, 'value', 'Invalid raw value.'); + return EmailType.unknown; } } diff --git a/lib/src/enums/encryption_type.dart b/lib/src/enums/encryption_type.dart index 7e9b3ca84..65624591b 100644 --- a/lib/src/enums/encryption_type.dart +++ b/lib/src/enums/encryption_type.dart @@ -1,7 +1,7 @@ /// Wifi encryption type constants. enum EncryptionType { /// Unknown encryption type. - none(0), + unknown(0), /// Not encrypted. open(1), @@ -14,10 +14,15 @@ enum EncryptionType { const EncryptionType(this.rawValue); + @Deprecated( + 'EncryptionType.none is deprecated. Use EncryptionType.unknown instead.', + ) + static const EncryptionType none = EncryptionType.unknown; + factory EncryptionType.fromRawValue(int value) { switch (value) { case 0: - return EncryptionType.none; + return EncryptionType.unknown; case 1: return EncryptionType.open; case 2: @@ -25,7 +30,7 @@ enum EncryptionType { case 3: return EncryptionType.wep; default: - throw ArgumentError.value(value, 'value', 'Invalid raw value.'); + return EncryptionType.unknown; } } diff --git a/lib/src/enums/phone_type.dart b/lib/src/enums/phone_type.dart index 81e684a96..8f51f08cf 100644 --- a/lib/src/enums/phone_type.dart +++ b/lib/src/enums/phone_type.dart @@ -30,7 +30,7 @@ enum PhoneType { case 4: return PhoneType.mobile; default: - throw ArgumentError.value(value, 'value', 'Invalid raw value.'); + return PhoneType.unknown; } } diff --git a/lib/src/objects/wifi.dart b/lib/src/objects/wifi.dart index 2505e8f02..5dc295d33 100644 --- a/lib/src/objects/wifi.dart +++ b/lib/src/objects/wifi.dart @@ -5,7 +5,7 @@ import 'package:mobile_scanner/src/enums/encryption_type.dart'; class WiFi { /// Construct a new [WiFi] instance. const WiFi({ - this.encryptionType = EncryptionType.none, + this.encryptionType = EncryptionType.unknown, this.ssid, this.password, }); diff --git a/lib/src/web/mobile_scanner_web.dart b/lib/src/web/mobile_scanner_web.dart index e3ada8c8d..963c13d87 100644 --- a/lib/src/web/mobile_scanner_web.dart +++ b/lib/src/web/mobile_scanner_web.dart @@ -88,6 +88,18 @@ class MobileScannerWeb extends MobileScannerPlatform { ..transformOrigin = 'center' ..pointerEvents = 'none'; + // Do not show the media controls, as this is a preview element. + // Also prevent play/pause events from changing the media controls. + videoElement.controls = false; + + videoElement.onplay = (JSAny _) { + videoElement.controls = false; + }.toJS; + + videoElement.onpause = (JSAny _) { + videoElement.controls = false; + }.toJS; + // Attach the video element to its parent container // and setup the PlatformView factory for this `textureId`. _divElement = HTMLDivElement() diff --git a/macos/mobile_scanner.podspec b/macos/mobile_scanner.podspec index 2e5e5122b..94d5a7cda 100644 --- a/macos/mobile_scanner.podspec +++ b/macos/mobile_scanner.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'mobile_scanner' - s.version = '5.2.2' + s.version = '5.2.3' s.summary = 'An universal scanner for Flutter based on MLKit.' s.description = <<-DESC An universal scanner for Flutter based on MLKit. diff --git a/pubspec.yaml b/pubspec.yaml index 4997e7909..80cdce43e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: mobile_scanner description: A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS. -version: 5.2.2 +version: 5.2.3 repository: https://github.com/juliansteenbakker/mobile_scanner screenshots: diff --git a/test/enums/address_type_test.dart b/test/enums/address_type_test.dart index ec4a36f7c..3c8913a38 100644 --- a/test/enums/address_type_test.dart +++ b/test/enums/address_type_test.dart @@ -17,12 +17,12 @@ void main() { } }); - test('invalid raw value throws argument error', () { + test('invalid raw value returns AddressType.unknown', () { const int negative = -1; const int outOfRange = 3; - expect(() => AddressType.fromRawValue(negative), throwsArgumentError); - expect(() => AddressType.fromRawValue(outOfRange), throwsArgumentError); + expect(AddressType.fromRawValue(negative), AddressType.unknown); + expect(AddressType.fromRawValue(outOfRange), AddressType.unknown); }); test('can be converted to raw value', () { diff --git a/test/enums/barcode_type_test.dart b/test/enums/barcode_type_test.dart index 0c0cb09a6..7d9f762fc 100644 --- a/test/enums/barcode_type_test.dart +++ b/test/enums/barcode_type_test.dart @@ -27,12 +27,12 @@ void main() { } }); - test('invalid raw value throws argument error', () { + test('invalid raw value returns BarcodeType.unknown', () { const int negative = -1; const int outOfRange = 13; - expect(() => BarcodeType.fromRawValue(negative), throwsArgumentError); - expect(() => BarcodeType.fromRawValue(outOfRange), throwsArgumentError); + expect(BarcodeType.fromRawValue(negative), BarcodeType.unknown); + expect(BarcodeType.fromRawValue(outOfRange), BarcodeType.unknown); }); test('can be converted to raw value', () { diff --git a/test/enums/email_type_test.dart b/test/enums/email_type_test.dart index d83e6921c..b69a49a8c 100644 --- a/test/enums/email_type_test.dart +++ b/test/enums/email_type_test.dart @@ -17,12 +17,12 @@ void main() { } }); - test('invalid raw value throws argument error', () { + test('invalid raw value returns EmailType.unknown', () { const int negative = -1; const int outOfRange = 3; - expect(() => EmailType.fromRawValue(negative), throwsArgumentError); - expect(() => EmailType.fromRawValue(outOfRange), throwsArgumentError); + expect(EmailType.fromRawValue(negative), EmailType.unknown); + expect(EmailType.fromRawValue(outOfRange), EmailType.unknown); }); test('can be converted to raw value', () { diff --git a/test/enums/encryption_type_test.dart b/test/enums/encryption_type_test.dart index ae8ae7b1e..30a788801 100644 --- a/test/enums/encryption_type_test.dart +++ b/test/enums/encryption_type_test.dart @@ -5,7 +5,7 @@ void main() { group('$EncryptionType tests', () { test('can be created from raw value', () { const values = { - 0: EncryptionType.none, + 0: EncryptionType.unknown, 1: EncryptionType.open, 2: EncryptionType.wpa, 3: EncryptionType.wep, @@ -18,20 +18,17 @@ void main() { } }); - test('invalid raw value throws argument error', () { + test('invalid raw value returns EncryptionType.unknown', () { const int negative = -1; const int outOfRange = 4; - expect(() => EncryptionType.fromRawValue(negative), throwsArgumentError); - expect( - () => EncryptionType.fromRawValue(outOfRange), - throwsArgumentError, - ); + expect(EncryptionType.fromRawValue(negative), EncryptionType.unknown); + expect(EncryptionType.fromRawValue(outOfRange), EncryptionType.unknown); }); test('can be converted to raw value', () { const values = { - EncryptionType.none: 0, + EncryptionType.unknown: 0, EncryptionType.open: 1, EncryptionType.wpa: 2, EncryptionType.wep: 3, diff --git a/test/enums/phone_type_test.dart b/test/enums/phone_type_test.dart index f518a79f4..f19c6a5a7 100644 --- a/test/enums/phone_type_test.dart +++ b/test/enums/phone_type_test.dart @@ -19,12 +19,12 @@ void main() { } }); - test('invalid raw value throws argument error', () { + test('invalid raw value returns PhoneType.unknown', () { const int negative = -1; const int outOfRange = 5; - expect(() => PhoneType.fromRawValue(negative), throwsArgumentError); - expect(() => PhoneType.fromRawValue(outOfRange), throwsArgumentError); + expect(PhoneType.fromRawValue(negative), PhoneType.unknown); + expect(PhoneType.fromRawValue(outOfRange), PhoneType.unknown); }); test('can be converted to raw value', () {