From d3a48a9fe335d6165fb2a576bf48307d570a351b Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Fri, 29 Oct 2021 14:56:09 -0400 Subject: [PATCH 1/4] feat(device_info_plus): add toMap method to WebBrowserInfo --- .../lib/model/web_browser_info.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart b/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart index 4b6a094bb2..8e5dc697d2 100644 --- a/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart +++ b/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart @@ -126,6 +126,26 @@ class WebBrowserInfo { ); } + /// Serializes [ WebBrowserInfo ] to a map. + Map toMap() { + return { + 'appCodeName': appCodeName, + 'appName': appName, + 'appVersion': appVersion, + 'deviceMemory': deviceMemory, + 'language': language, + 'languages': languages, + 'platform': platform, + 'product': product, + 'productSub': productSub, + 'userAgent': userAgent, + 'vendor': vendor, + 'vendorSub': vendorSub, + 'hardwareConcurrency': hardwareConcurrency, + 'maxTouchPoints': maxTouchPoints, + }; + } + BrowserName _parseUserAgentToBrowserName() { final _userAgent = userAgent; if (_userAgent == null) { From bb53fe7ae98977b33d6f355decf8a6622a78a3f2 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Fri, 29 Oct 2021 15:45:22 -0400 Subject: [PATCH 2/4] test(device_info_plus): webBrowserInfo --- .../device_info_plus/lib/device_info_plus.dart | 3 ++- .../lib/model/web_browser_info.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/device_info_plus/device_info_plus/lib/device_info_plus.dart b/packages/device_info_plus/device_info_plus/lib/device_info_plus.dart index 81ad1e8a27..a4c777f12a 100644 --- a/packages/device_info_plus/device_info_plus/lib/device_info_plus.dart +++ b/packages/device_info_plus/device_info_plus/lib/device_info_plus.dart @@ -14,7 +14,8 @@ export 'package:device_info_plus_platform_interface/device_info_plus_platform_in LinuxDeviceInfo, MacOsDeviceInfo, WindowsDeviceInfo, - WebBrowserInfo; + WebBrowserInfo, + BrowserName; /// Provides device and operating system information. class DeviceInfoPlugin { diff --git a/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart b/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart index 8e5dc697d2..1ae7be5e65 100644 --- a/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart +++ b/packages/device_info_plus/device_info_plus_platform_interface/lib/model/web_browser_info.dart @@ -129,6 +129,7 @@ class WebBrowserInfo { /// Serializes [ WebBrowserInfo ] to a map. Map toMap() { return { + 'browserName': browserName, 'appCodeName': appCodeName, 'appName': appName, 'appVersion': appVersion, From c36e0a740da4c8a12e3d7c2f65f19e8e495c3077 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Fri, 29 Oct 2021 16:33:27 -0400 Subject: [PATCH 3/4] test(device_info_plus): webBrowserInfo --- .../test/model/web_browser_info_test.dart | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packages/device_info_plus/device_info_plus_platform_interface/test/model/web_browser_info_test.dart diff --git a/packages/device_info_plus/device_info_plus_platform_interface/test/model/web_browser_info_test.dart b/packages/device_info_plus/device_info_plus_platform_interface/test/model/web_browser_info_test.dart new file mode 100644 index 0000000000..8529d4b8a8 --- /dev/null +++ b/packages/device_info_plus/device_info_plus_platform_interface/test/model/web_browser_info_test.dart @@ -0,0 +1,51 @@ +import 'package:device_info_plus_platform_interface/model/web_browser_info.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('$WebBrowserInfo', () { + group('fromMap | toMap', () { + const webBrowserInfoMap = { + 'browserName': BrowserName.safari, + 'appCodeName': 'appCodeName', + 'appName': 'appName', + 'appVersion': 'appVersion', + 'deviceMemory': 42, + 'language': 'language', + 'languages': ['en', 'es'], + 'platform': 'platform', + 'product': 'product', + 'productSub': 'productSub', + 'userAgent': 'Safari', + 'vendor': 'vendor', + 'vendorSub': 'vendorSub', + 'hardwareConcurrency': 2, + 'maxTouchPoints': 42, + }; + + test('fromMap should return $WebBrowserInfo with correct values', () { + final webBrowserInfo = WebBrowserInfo.fromMap(webBrowserInfoMap); + + expect(webBrowserInfo.browserName, BrowserName.safari); + expect(webBrowserInfo.appCodeName, 'appCodeName'); + expect(webBrowserInfo.appName, 'appName'); + expect(webBrowserInfo.appVersion, 'appVersion'); + expect(webBrowserInfo.deviceMemory, 42); + expect(webBrowserInfo.language, 'language'); + expect(webBrowserInfo.languages, ['en', 'es']); + expect(webBrowserInfo.platform, 'platform'); + expect(webBrowserInfo.product, 'product'); + expect(webBrowserInfo.productSub, 'productSub'); + expect(webBrowserInfo.userAgent, 'Safari'); + expect(webBrowserInfo.vendor, 'vendor'); + expect(webBrowserInfo.vendorSub, 'vendorSub'); + expect(webBrowserInfo.hardwareConcurrency, 2); + expect(webBrowserInfo.maxTouchPoints, 42); + }); + + test('toMap should return map with correct key and map', () { + final webBrowserInfo = WebBrowserInfo.fromMap(webBrowserInfoMap); + expect(webBrowserInfo.toMap(), webBrowserInfoMap); + }); + }); + }); +} From 429c5038e9d8597835452309b9bb418860399880 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Wed, 3 Nov 2021 09:06:55 -0400 Subject: [PATCH 4/4] chore(device_info_plus): bump plugin versions --- packages/device_info_plus/device_info_plus/CHANGELOG.md | 4 ++++ packages/device_info_plus/device_info_plus/pubspec.yaml | 2 +- .../device_info_plus_platform_interface/CHANGELOG.md | 4 ++++ .../device_info_plus_platform_interface/pubspec.yaml | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/device_info_plus/device_info_plus/CHANGELOG.md b/packages/device_info_plus/device_info_plus/CHANGELOG.md index e3ad044fd0..4989e9f9ab 100644 --- a/packages/device_info_plus/device_info_plus/CHANGELOG.md +++ b/packages/device_info_plus/device_info_plus/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.1.1 + +- add toMap to WebBrowserInfo + ## 3.1.0 - add System GUID to MacOS diff --git a/packages/device_info_plus/device_info_plus/pubspec.yaml b/packages/device_info_plus/device_info_plus/pubspec.yaml index 71340a69a5..94a4d3506d 100644 --- a/packages/device_info_plus/device_info_plus/pubspec.yaml +++ b/packages/device_info_plus/device_info_plus/pubspec.yaml @@ -1,7 +1,7 @@ name: device_info_plus description: Flutter plugin providing detailed information about the device (make, model, etc.), and Android or iOS version the app is running on. -version: 3.1.0 +version: 3.1.1 homepage: https://plus.fluttercommunity.dev/ repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ diff --git a/packages/device_info_plus/device_info_plus_platform_interface/CHANGELOG.md b/packages/device_info_plus/device_info_plus_platform_interface/CHANGELOG.md index ec6b9a79c1..f2ab65f034 100644 --- a/packages/device_info_plus/device_info_plus_platform_interface/CHANGELOG.md +++ b/packages/device_info_plus/device_info_plus_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.1 + +- add toMap to WebBrowserInfo + ## 2.2.0 - add System GUID to MacOS diff --git a/packages/device_info_plus/device_info_plus_platform_interface/pubspec.yaml b/packages/device_info_plus/device_info_plus_platform_interface/pubspec.yaml index 6b73b063ca..a23881d055 100644 --- a/packages/device_info_plus/device_info_plus_platform_interface/pubspec.yaml +++ b/packages/device_info_plus/device_info_plus_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: device_info_plus_platform_interface -description: A common platform interface for the device_info_plis plugin. -version: 2.2.0 +description: A common platform interface for the device_info_plus plugin. +version: 2.2.1 homepage: https://plus.fluttercommunity.dev/ repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/