From 6e9e671f7a792c8f0359cd429b17b79e5a8eff79 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 19 Feb 2021 14:37:49 -0800 Subject: [PATCH 1/9] migrate platform interface --- .../device_info_platform_interface/CHANGELOG.md | 9 +-------- .../device_info_platform_interface/pubspec.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/CHANGELOG.md b/packages/device_info/device_info_platform_interface/CHANGELOG.md index d4bc81e0f0aa..663352ad2a42 100644 --- a/packages/device_info/device_info_platform_interface/CHANGELOG.md +++ b/packages/device_info/device_info_platform_interface/CHANGELOG.md @@ -1,14 +1,7 @@ -## 2.0.0-nullsafety.2 +## 2.0.0 * Make `baseOS`, `previewSdkInt`, and `securityPatch` nullable types. * Remove default values for non-nullable types. - -## 2.0.0-nullsafety.1 - -* Bump Dart SDK to support null safety. - -## 2.0.0-nullsafety - * Migrate to null safety. ## 1.0.2 diff --git a/packages/device_info/device_info_platform_interface/pubspec.yaml b/packages/device_info/device_info_platform_interface/pubspec.yaml index ca72cc753b63..3887aea3eff2 100644 --- a/packages/device_info/device_info_platform_interface/pubspec.yaml +++ b/packages/device_info/device_info_platform_interface/pubspec.yaml @@ -3,20 +3,20 @@ description: A common platform interface for the device_info plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/device_info # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.0.0-nullsafety.2 +version: 2.0.0 dependencies: flutter: sdk: flutter - meta: ^1.3.0-nullsafety.3 - plugin_platform_interface: ^1.1.0-nullsafety.1 + meta: ^1.3.0 + plugin_platform_interface: ">=1.0.0 <3.0.0" dev_dependencies: flutter_test: sdk: flutter - test: ^1.10.0-nullsafety.1 - pedantic: ^1.10.0-nullsafety.1 + test: ^1.16.3 + pedantic: ^1.10.0 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.9.1+hotfix.4" From 9ba17a78e595c0e65b3dbdc654d726b8bac55f93 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 22 Feb 2021 16:41:22 -0800 Subject: [PATCH 2/9] fix nullable types --- packages/device_info/device_info/CHANGELOG.md | 11 +- .../device_info/example/pubspec.yaml | 4 +- packages/device_info/device_info/pubspec.yaml | 9 +- .../method_channel_device_info.dart | 5 +- .../lib/model/android_device_info.dart | 57 +++-- .../lib/model/ios_device_info.dart | 26 +- .../test/method_channel_device_info_test.dart | 224 ++++++++++++++++++ 7 files changed, 279 insertions(+), 57 deletions(-) diff --git a/packages/device_info/device_info/CHANGELOG.md b/packages/device_info/device_info/CHANGELOG.md index 910d265b7c3e..f849131eff19 100644 --- a/packages/device_info/device_info/CHANGELOG.md +++ b/packages/device_info/device_info/CHANGELOG.md @@ -1,14 +1,7 @@ -## 2.0.0-nullsafety.2 - -* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) - -## 2.0.0-nullsafety.1 - -* Bump Dart SDK to support null safety. - -## 2.0.0-nullsafety +## 2.0.0 * Migrate to null safety. +* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) ## 1.0.1 diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index 1f636977c2a9..bc7d00ef87f0 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -17,11 +17,11 @@ dev_dependencies: sdk: flutter integration_test: path: ../../../integration_test - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 flutter: uses-material-design: true environment: - sdk: ">=2.10.0-56.0.dev <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/device_info/device_info/pubspec.yaml b/packages/device_info/device_info/pubspec.yaml index bcdc7c8b54d1..fba33d727bad 100644 --- a/packages/device_info/device_info/pubspec.yaml +++ b/packages/device_info/device_info/pubspec.yaml @@ -16,13 +16,14 @@ flutter: dependencies: flutter: sdk: flutter - device_info_platform_interface: ^2.0.0-nullsafety.1 + device_info_platform_interface: + path: ../device_info_platform_interface dev_dependencies: - test: ^1.10.0-nullsafety.1 + test: ^1.16.3 flutter_test: sdk: flutter - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart index 7bd02e97436d..bdd68594f110 100644 --- a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart @@ -14,15 +14,14 @@ class MethodChannelDeviceInfo extends DeviceInfoPlatform { // Method channel for Android devices Future androidInfo() async { return AndroidDeviceInfo.fromMap( - (await channel.invokeMethod('getAndroidDeviceInfo')) - .cast(), + (await channel.invokeMapMethod('getAndroidDeviceInfo')) ?? {} ); } // Method channel for iOS devices Future iosInfo() async { return IosDeviceInfo.fromMap( - (await channel.invokeMethod('getIosDeviceInfo')).cast(), + (await channel.invokeMapMethod('getIosDeviceInfo')) ?? {} ); } } diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index 4fb940c3effa..e0c36bd233d2 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -114,33 +114,38 @@ class AndroidDeviceInfo { static AndroidDeviceInfo fromMap(Map map) { return AndroidDeviceInfo( version: - AndroidBuildVersion._fromMap(map['version']!.cast()), - board: map['board']!, - bootloader: map['bootloader']!, - brand: map['brand']!, - device: map['device']!, - display: map['display']!, - fingerprint: map['fingerprint']!, - hardware: map['hardware']!, - host: map['host']!, - id: map['id']!, - manufacturer: map['manufacturer']!, - model: map['model']!, - product: map['product']!, - supported32BitAbis: _fromList(map['supported32BitAbis']!), - supported64BitAbis: _fromList(map['supported64BitAbis']!), - supportedAbis: _fromList(map['supportedAbis']!), - tags: map['tags']!, - type: map['type']!, - isPhysicalDevice: map['isPhysicalDevice']!, - androidId: map['androidId']!, - systemFeatures: _fromList(map['systemFeatures']!), + AndroidBuildVersion._fromMap(map['version'] != null ? map['version'].cast() : {}), + board: map['board'] ?? '', + bootloader: map['bootloader'] ?? '', + brand: map['brand'] ?? '', + device: map['device'] ?? '', + display: map['display'] ?? '', + fingerprint: map['fingerprint'] ?? '', + hardware: map['hardware'] ?? '', + host: map['host'] ?? '', + id: map['id'] ?? '', + manufacturer: map['manufacturer'] ?? '', + model: map['model'] ?? '', + product: map['product'] ?? '', + supported32BitAbis: _fromList(map['supported32BitAbis']), + supported64BitAbis: _fromList(map['supported64BitAbis']), + supportedAbis: _fromList(map['supportedAbis']), + tags: map['tags'] ?? '', + type: map['type'] ?? '', + isPhysicalDevice: map['isPhysicalDevice'] ?? false, + androidId: map['androidId'] ?? '', + systemFeatures: _fromList(map['systemFeatures']), ); } /// Deserializes message as List static List _fromList(dynamic message) { - final List list = message; + if (message == null) { + return []; + } + assert(message is List); + final List list = List.from(message)..removeWhere((value) => value == null); + print(list); return List.from(list); } } @@ -192,10 +197,10 @@ class AndroidBuildVersion { baseOS: map['baseOS'], previewSdkInt: map['previewSdkInt'], securityPatch: map['securityPatch'], - codename: map['codename']!, - incremental: map['incremental']!, - release: map['release']!, - sdkInt: map['sdkInt']!, + codename: map['codename'] ?? '', + incremental: map['incremental'] ?? '', + release: map['release'] ?? '', + sdkInt: map['sdkInt'] ?? -1, ); } } diff --git a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart index eb6e5874073b..027a342f1282 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart @@ -45,14 +45,14 @@ class IosDeviceInfo { /// Deserializes from the map message received from [_kChannel]. static IosDeviceInfo fromMap(Map map) { return IosDeviceInfo( - name: map['name']!, - systemName: map['systemName']!, - systemVersion: map['systemVersion']!, - model: map['model']!, - localizedModel: map['localizedModel']!, - identifierForVendor: map['identifierForVendor']!, - isPhysicalDevice: map['isPhysicalDevice'] == 'true', - utsname: IosUtsname._fromMap(map['utsname']!.cast()), + name: map['name'] ?? '', + systemName: map['systemName'] ?? '', + systemVersion: map['systemVersion'] ?? '', + model: map['model'] ?? '', + localizedModel: map['localizedModel'] ?? '', + identifierForVendor: map['identifierForVendor'] ?? '', + isPhysicalDevice: map['isPhysicalDevice'] != null ? map['isPhysicalDevice'] == 'true' : false, + utsname: IosUtsname._fromMap(map['utsname'] != null ? map['utsname'].cast() : {}), ); } } @@ -86,11 +86,11 @@ class IosUtsname { /// Deserializes from the map message received from [_kChannel]. static IosUtsname _fromMap(Map map) { return IosUtsname._( - sysname: map['sysname']!, - nodename: map['nodename']!, - release: map['release']!, - version: map['version']!, - machine: map['machine']!, + sysname: map['sysname'] ?? '', + nodename: map['nodename'] ?? '', + release: map['release'] ?? '', + version: map['version'] ?? '', + machine: map['machine'] ?? '', ); } } diff --git a/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart b/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart index 15963854ab12..c1f21f3c6f5b 100644 --- a/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart +++ b/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart @@ -158,4 +158,228 @@ void main() { expect(result.utsname.machine, "x86_64"); }); }); + + + group("$MethodChannelDeviceInfo handles null value in the map returned from method channel", () { + MethodChannelDeviceInfo methodChannelDeviceInfo; + + setUp(() async { + methodChannelDeviceInfo = MethodChannelDeviceInfo(); + + methodChannelDeviceInfo.channel + .setMockMethodCallHandler((MethodCall methodCall) async { + switch (methodCall.method) { + case 'getAndroidDeviceInfo': + return ({ + "version": null, + "board": null, + "bootloader": null, + "brand": null, + "device": null, + "display": null, + "fingerprint": + null, + "hardware": null, + "host": null, + "id": null, + "manufacturer": null, + "model": null, + "product": null, + "supported32BitAbis": null, + "supported64BitAbis": null, + "supportedAbis": null, + "tags": null, + "type": null, + "isPhysicalDevice": null, + "androidId": null, + "systemFeatures": null, + }); + case 'getIosDeviceInfo': + return ({ + "name": null, + "systemName": null, + "systemVersion": null, + "model": null, + "localizedModel": null, + "identifierForVendor": null, + "isPhysicalDevice": null, + "utsname": null, + }); + default: + return null; + } + }); + }); + + test("androidInfo hanels null", () async { + final AndroidDeviceInfo result = + await methodChannelDeviceInfo.androidInfo(); + + expect(result.version.securityPatch, null); + expect(result.version.sdkInt, -1); + expect(result.version.release, ''); + expect(result.version.previewSdkInt, null); + expect(result.version.incremental, ''); + expect(result.version.codename, ''); + expect(result.board, ''); + expect(result.bootloader, ''); + expect(result.brand, ''); + expect(result.device, ''); + expect(result.display, ''); + expect(result.fingerprint, ''); + expect(result.hardware, ''); + expect(result.host, ''); + expect(result.id, ''); + expect(result.manufacturer, ''); + expect(result.model, ''); + expect(result.product, ''); + expect(result.supported32BitAbis, []); + expect(result.supported64BitAbis, []); + expect(result.supportedAbis, []); + expect(result.tags, ''); + expect(result.type, ''); + expect(result.isPhysicalDevice, false); + expect(result.androidId, ''); + expect(result.systemFeatures, []); + }); + + test("iosInfo handles null", () async { + final IosDeviceInfo result = await methodChannelDeviceInfo.iosInfo(); + expect(result.name, ''); + expect(result.systemName, ''); + expect(result.systemVersion, ''); + expect(result.model, ''); + expect(result.localizedModel, ''); + expect( + result.identifierForVendor, ''); + expect(result.isPhysicalDevice, false); + expect(result.utsname.sysname, ''); + expect(result.utsname.nodename, ''); + expect(result.utsname.release, ''); + expect(result.utsname.version, ''); + expect(result.utsname.machine, ''); + }); + }); + + group("$MethodChannelDeviceInfo handles method channel returns null", () { + MethodChannelDeviceInfo methodChannelDeviceInfo; + + setUp(() async { + methodChannelDeviceInfo = MethodChannelDeviceInfo(); + + methodChannelDeviceInfo.channel + .setMockMethodCallHandler((MethodCall methodCall) async { + switch (methodCall.method) { + case 'getAndroidDeviceInfo': + return null; + case 'getIosDeviceInfo': + return null; + default: + return null; + } + }); + }); + + test("androidInfo hanels null", () async { + final AndroidDeviceInfo result = + await methodChannelDeviceInfo.androidInfo(); + + expect(result.version.securityPatch, null); + expect(result.version.sdkInt, -1); + expect(result.version.release, ''); + expect(result.version.previewSdkInt, null); + expect(result.version.incremental, ''); + expect(result.version.codename, ''); + expect(result.board, ''); + expect(result.bootloader, ''); + expect(result.brand, ''); + expect(result.device, ''); + expect(result.display, ''); + expect(result.fingerprint, ''); + expect(result.hardware, ''); + expect(result.host, ''); + expect(result.id, ''); + expect(result.manufacturer, ''); + expect(result.model, ''); + expect(result.product, ''); + expect(result.supported32BitAbis, []); + expect(result.supported64BitAbis, []); + expect(result.supportedAbis, []); + expect(result.tags, ''); + expect(result.type, ''); + expect(result.isPhysicalDevice, false); + expect(result.androidId, ''); + expect(result.systemFeatures, []); + }); + + test("iosInfo handles null", () async { + final IosDeviceInfo result = await methodChannelDeviceInfo.iosInfo(); + expect(result.name, ''); + expect(result.systemName, ''); + expect(result.systemVersion, ''); + expect(result.model, ''); + expect(result.localizedModel, ''); + expect( + result.identifierForVendor, ''); + expect(result.isPhysicalDevice, false); + expect(result.utsname.sysname, ''); + expect(result.utsname.nodename, ''); + expect(result.utsname.release, ''); + expect(result.utsname.version, ''); + expect(result.utsname.machine, ''); + }); + }); + + group("$MethodChannelDeviceInfo android handles null values in list", () { + MethodChannelDeviceInfo methodChannelDeviceInfo; + + setUp(() async { + methodChannelDeviceInfo = MethodChannelDeviceInfo(); + + methodChannelDeviceInfo.channel + .setMockMethodCallHandler((MethodCall methodCall) async { + switch (methodCall.method) { + case 'getAndroidDeviceInfo': + return ({ + "supported32BitAbis": [ + "x86", null + ], + "supported64BitAbis": [ + "x86_64", null + ], + "supportedAbis": [ + "x86_64", + "x86", + null + ], + "systemFeatures": [ + "android.hardware.sensor.proximity", + "android.software.adoptable_storage", + "android.hardware.sensor.accelerometer", + "android.hardware.faketouch", + "android.software.backup", + "android.hardware.touchscreen", + null + ], + }); + default: + return null; + } + }); + }); + + test("androidInfo hanels null in list", () async { + final AndroidDeviceInfo result = + await methodChannelDeviceInfo.androidInfo(); + expect(result.supported32BitAbis, ['x86']); + expect(result.supported64BitAbis, ['x86_64']); + expect(result.supportedAbis, ['x86_64', 'x86']); + expect(result.systemFeatures, [ "android.hardware.sensor.proximity", + "android.software.adoptable_storage", + "android.hardware.sensor.accelerometer", + "android.hardware.faketouch", + "android.software.backup", + "android.hardware.touchscreen"]); + }); + }); } From c389a6ab9d8d26c1b380cd39df9a83095f376cc2 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 22 Feb 2021 16:41:52 -0800 Subject: [PATCH 3/9] format --- .../method_channel_device_info.dart | 10 ++--- .../lib/model/android_device_info.dart | 10 +++-- .../lib/model/ios_device_info.dart | 8 +++- .../test/method_channel_device_info_test.dart | 44 ++++++++----------- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart index bdd68594f110..5408b9d66c15 100644 --- a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart @@ -13,15 +13,15 @@ class MethodChannelDeviceInfo extends DeviceInfoPlatform { // Method channel for Android devices Future androidInfo() async { - return AndroidDeviceInfo.fromMap( - (await channel.invokeMapMethod('getAndroidDeviceInfo')) ?? {} - ); + return AndroidDeviceInfo.fromMap((await channel + .invokeMapMethod('getAndroidDeviceInfo')) ?? + {}); } // Method channel for iOS devices Future iosInfo() async { return IosDeviceInfo.fromMap( - (await channel.invokeMapMethod('getIosDeviceInfo')) ?? {} - ); + (await channel.invokeMapMethod('getIosDeviceInfo')) ?? + {}); } } diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index e0c36bd233d2..6e57e0bef7ec 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -113,8 +113,9 @@ class AndroidDeviceInfo { /// Deserializes from the message received from [_kChannel]. static AndroidDeviceInfo fromMap(Map map) { return AndroidDeviceInfo( - version: - AndroidBuildVersion._fromMap(map['version'] != null ? map['version'].cast() : {}), + version: AndroidBuildVersion._fromMap(map['version'] != null + ? map['version'].cast() + : {}), board: map['board'] ?? '', bootloader: map['bootloader'] ?? '', brand: map['brand'] ?? '', @@ -144,7 +145,8 @@ class AndroidDeviceInfo { return []; } assert(message is List); - final List list = List.from(message)..removeWhere((value) => value == null); + final List list = List.from(message) + ..removeWhere((value) => value == null); print(list); return List.from(list); } @@ -200,7 +202,7 @@ class AndroidBuildVersion { codename: map['codename'] ?? '', incremental: map['incremental'] ?? '', release: map['release'] ?? '', - sdkInt: map['sdkInt'] ?? -1, + sdkInt: map['sdkInt'] ?? -1, ); } } diff --git a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart index 027a342f1282..6d428af36660 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart @@ -51,8 +51,12 @@ class IosDeviceInfo { model: map['model'] ?? '', localizedModel: map['localizedModel'] ?? '', identifierForVendor: map['identifierForVendor'] ?? '', - isPhysicalDevice: map['isPhysicalDevice'] != null ? map['isPhysicalDevice'] == 'true' : false, - utsname: IosUtsname._fromMap(map['utsname'] != null ? map['utsname'].cast() : {}), + isPhysicalDevice: map['isPhysicalDevice'] != null + ? map['isPhysicalDevice'] == 'true' + : false, + utsname: IosUtsname._fromMap(map['utsname'] != null + ? map['utsname'].cast() + : {}), ); } } diff --git a/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart b/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart index c1f21f3c6f5b..d544be8e8fc6 100644 --- a/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart +++ b/packages/device_info/device_info_platform_interface/test/method_channel_device_info_test.dart @@ -159,8 +159,9 @@ void main() { }); }); - - group("$MethodChannelDeviceInfo handles null value in the map returned from method channel", () { + group( + "$MethodChannelDeviceInfo handles null value in the map returned from method channel", + () { MethodChannelDeviceInfo methodChannelDeviceInfo; setUp(() async { @@ -177,8 +178,7 @@ void main() { "brand": null, "device": null, "display": null, - "fingerprint": - null, + "fingerprint": null, "hardware": null, "host": null, "id": null, @@ -250,8 +250,7 @@ void main() { expect(result.systemVersion, ''); expect(result.model, ''); expect(result.localizedModel, ''); - expect( - result.identifierForVendor, ''); + expect(result.identifierForVendor, ''); expect(result.isPhysicalDevice, false); expect(result.utsname.sysname, ''); expect(result.utsname.nodename, ''); @@ -319,8 +318,7 @@ void main() { expect(result.systemVersion, ''); expect(result.model, ''); expect(result.localizedModel, ''); - expect( - result.identifierForVendor, ''); + expect(result.identifierForVendor, ''); expect(result.isPhysicalDevice, false); expect(result.utsname.sysname, ''); expect(result.utsname.nodename, ''); @@ -336,22 +334,14 @@ void main() { setUp(() async { methodChannelDeviceInfo = MethodChannelDeviceInfo(); - methodChannelDeviceInfo.channel + methodChannelDeviceInfo.channel .setMockMethodCallHandler((MethodCall methodCall) async { switch (methodCall.method) { case 'getAndroidDeviceInfo': return ({ - "supported32BitAbis": [ - "x86", null - ], - "supported64BitAbis": [ - "x86_64", null - ], - "supportedAbis": [ - "x86_64", - "x86", - null - ], + "supported32BitAbis": ["x86", null], + "supported64BitAbis": ["x86_64", null], + "supportedAbis": ["x86_64", "x86", null], "systemFeatures": [ "android.hardware.sensor.proximity", "android.software.adoptable_storage", @@ -374,12 +364,14 @@ void main() { expect(result.supported32BitAbis, ['x86']); expect(result.supported64BitAbis, ['x86_64']); expect(result.supportedAbis, ['x86_64', 'x86']); - expect(result.systemFeatures, [ "android.hardware.sensor.proximity", - "android.software.adoptable_storage", - "android.hardware.sensor.accelerometer", - "android.hardware.faketouch", - "android.software.backup", - "android.hardware.touchscreen"]); + expect(result.systemFeatures, [ + "android.hardware.sensor.proximity", + "android.software.adoptable_storage", + "android.hardware.sensor.accelerometer", + "android.hardware.faketouch", + "android.software.backup", + "android.hardware.touchscreen" + ]); }); }); } From a9f0a0acf9998dd33d09c84074b60630225c4142 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 22 Feb 2021 16:46:57 -0800 Subject: [PATCH 4/9] revert test code in device info --- packages/device_info/device_info/CHANGELOG.md | 9 +++++++-- packages/device_info/device_info/example/pubspec.yaml | 4 ++-- packages/device_info/device_info/pubspec.yaml | 9 ++++----- .../lib/model/android_device_info.dart | 1 - 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/device_info/device_info/CHANGELOG.md b/packages/device_info/device_info/CHANGELOG.md index f849131eff19..8c9d489dddac 100644 --- a/packages/device_info/device_info/CHANGELOG.md +++ b/packages/device_info/device_info/CHANGELOG.md @@ -1,8 +1,13 @@ -## 2.0.0 +## 2.0.0-nullsafety.2 -* Migrate to null safety. * Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) +## 2.0.0-nullsafety.1 + +* Bump Dart SDK to support null safety. + +## 2.0.0-nullsafety + ## 1.0.1 * Update Flutter SDK constraint. diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index bc7d00ef87f0..1f636977c2a9 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -17,11 +17,11 @@ dev_dependencies: sdk: flutter integration_test: path: ../../../integration_test - pedantic: ^1.10.0 + pedantic: ^1.10.0-nullsafety.1 flutter: uses-material-design: true environment: - sdk: ">=2.12.0-259.9.beta <3.0.0" + sdk: ">=2.10.0-56.0.dev <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/device_info/device_info/pubspec.yaml b/packages/device_info/device_info/pubspec.yaml index fba33d727bad..bcdc7c8b54d1 100644 --- a/packages/device_info/device_info/pubspec.yaml +++ b/packages/device_info/device_info/pubspec.yaml @@ -16,14 +16,13 @@ flutter: dependencies: flutter: sdk: flutter - device_info_platform_interface: - path: ../device_info_platform_interface + device_info_platform_interface: ^2.0.0-nullsafety.1 dev_dependencies: - test: ^1.16.3 + test: ^1.10.0-nullsafety.1 flutter_test: sdk: flutter - pedantic: ^1.10.0 + pedantic: ^1.10.0-nullsafety.1 environment: - sdk: ">=2.12.0-259.9.beta <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index 6e57e0bef7ec..54e5cdaf1e71 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -147,7 +147,6 @@ class AndroidDeviceInfo { assert(message is List); final List list = List.from(message) ..removeWhere((value) => value == null); - print(list); return List.from(list); } } From c6a15a896b338977a9649a7969c6e9d14047ce08 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 22 Feb 2021 16:48:11 -0800 Subject: [PATCH 5/9] revert test code --- packages/device_info/device_info/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/device_info/device_info/CHANGELOG.md b/packages/device_info/device_info/CHANGELOG.md index 8c9d489dddac..910d265b7c3e 100644 --- a/packages/device_info/device_info/CHANGELOG.md +++ b/packages/device_info/device_info/CHANGELOG.md @@ -8,6 +8,8 @@ ## 2.0.0-nullsafety +* Migrate to null safety. + ## 1.0.1 * Update Flutter SDK constraint. From fefc6dbe1f2cefe4755d46ad4948518345955471 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 22 Feb 2021 17:30:13 -0800 Subject: [PATCH 6/9] some cleanup --- .../lib/device_info_platform_interface.dart | 4 ---- .../lib/method_channel/method_channel_device_info.dart | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart b/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart index 808b7adf9dc7..3dfed9cab067 100644 --- a/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart +++ b/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart @@ -3,14 +3,10 @@ // found in the LICENSE file. import 'dart:async'; - import 'package:plugin_platform_interface/plugin_platform_interface.dart'; - import 'method_channel/method_channel_device_info.dart'; - import 'model/android_device_info.dart'; import 'model/ios_device_info.dart'; - export 'model/android_device_info.dart'; export 'model/ios_device_info.dart'; diff --git a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart index 5408b9d66c15..63eb4fb9ee00 100644 --- a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart @@ -1,8 +1,10 @@ -import 'dart:async'; +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +import 'dart:async'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; - import 'package:device_info_platform_interface/device_info_platform_interface.dart'; /// An implementation of [DeviceInfoPlatform] that uses method channels. From dedd740f1e385ef86382b8f679af4c1fe2c646d1 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 23 Feb 2021 09:15:36 -0800 Subject: [PATCH 7/9] review --- .../lib/device_info_platform_interface.dart | 2 ++ .../lib/method_channel/method_channel_device_info.dart | 1 + .../lib/model/android_device_info.dart | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart b/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart index 3dfed9cab067..2dd41dcc580f 100644 --- a/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart +++ b/packages/device_info/device_info_platform_interface/lib/device_info_platform_interface.dart @@ -3,7 +3,9 @@ // found in the LICENSE file. import 'dart:async'; + import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + import 'method_channel/method_channel_device_info.dart'; import 'model/android_device_info.dart'; import 'model/ios_device_info.dart'; diff --git a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart index 63eb4fb9ee00..331f718989ce 100644 --- a/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/method_channel/method_channel_device_info.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; + import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; import 'package:device_info_platform_interface/device_info_platform_interface.dart'; diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index 54e5cdaf1e71..ad073201a2fe 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -147,7 +147,7 @@ class AndroidDeviceInfo { assert(message is List); final List list = List.from(message) ..removeWhere((value) => value == null); - return List.from(list); + return list.cast(); } } From 3d351f155b922c3dbe0e5819790bd32f30a4f7cb Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 23 Feb 2021 10:58:39 -0800 Subject: [PATCH 8/9] add docs to explain empty value --- .../lib/model/android_device_info.dart | 42 ++++++++++++++++++- .../lib/model/ios_device_info.dart | 28 ++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index ad073201a2fe..c5210ab10f50 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -38,39 +38,63 @@ class AndroidDeviceInfo { final AndroidBuildVersion version; /// The name of the underlying board, like "goldfish". + /// + /// The value is an empty String if it is not available. final String board; /// The system bootloader version number. + /// + /// The value is an empty String if it is not available. final String bootloader; /// The consumer-visible brand with which the product/hardware will be associated, if any. + /// + /// The value is an empty String if it is not available. final String brand; /// The name of the industrial design. + /// + /// The value is an empty String if it is not available. final String device; /// A build ID string meant for displaying to the user. + /// + /// The value is an empty String if it is not available. final String display; /// A string that uniquely identifies this build. + /// + /// The value is an empty String if it is not available. final String fingerprint; /// The name of the hardware (from the kernel command line or /proc). + /// + /// The value is an empty String if it is not available. final String hardware; /// Hostname. + /// + /// The value is an empty String if it is not available. final String host; /// Either a changelist number, or a label like "M4-rc20". + /// + /// The value is an empty String if it is not available. final String id; /// The manufacturer of the product/hardware. + /// + /// The value is an empty String if it is not available. final String manufacturer; /// The end-user-visible name for the end product. + /// + /// The value is an empty String if it is not available. final String model; /// The name of the overall product. + /// + /// The value is an empty String if it is not available. final String product; /// An ordered list of 32 bit ABIs supported by this device. @@ -83,15 +107,23 @@ class AndroidDeviceInfo { final List supportedAbis; /// Comma-separated tags describing the build, like "unsigned,debug". + /// + /// The value is an empty String if it is not available. final String tags; /// The type of build, like "user" or "eng". + /// + /// The value is an empty String if it is not available. final String type; - /// `false` if the application is running in an emulator, `true` otherwise. + /// The value is `true` if the application is running on a physical device. + /// + /// The value is `false` when the application is running on a emulator, or the value is unavailable. final bool isPhysicalDevice; /// The Android hardware device ID that is unique between the device + user and app signing. + /// + /// The value is an empty String if it is not available. final String androidId; /// Describes what features are available on the current device. @@ -179,17 +211,25 @@ class AndroidBuildVersion { final String? securityPatch; /// The current development codename, or the string "REL" if this is a release build. + /// + /// The value is an empty String if it is not available. final String codename; /// The internal value used by the underlying source control to represent this build. + /// + /// The value is an empty String if it is not available. final String incremental; /// The user-visible version string. + /// + /// The value is an empty String if it is not available. final String release; /// The user-visible SDK version of the framework. /// /// Possible values are defined in: https://developer.android.com/reference/android/os/Build.VERSION_CODES.html + /// + /// The value is -1 if it is unavailable. final int sdkInt; /// Deserializes from the map message received from [_kChannel]. diff --git a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart index 6d428af36660..20ec8362f66d 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart @@ -19,27 +19,43 @@ class IosDeviceInfo { }); /// Device name. + /// + /// The value is an empty String if it is not available. final String name; /// The name of the current operating system. + /// + /// The value is an empty String if it is not available. final String systemName; /// The current operating system version. + /// + /// The value is an empty String if it is not available. final String systemVersion; /// Device model. + /// + /// The value is an empty String if it is not available. final String model; /// Localized name of the device model. + /// + /// The value is an empty String if it is not available. final String localizedModel; /// Unique UUID value identifying the current device. + /// + /// The value is an empty String if it is not available. final String identifierForVendor; - /// `false` if the application is running in a simulator, `true` otherwise. + /// The value is `true` if the application is running on a physical device. + /// + /// The value is `false` when the application is running on a simulator, or the value is unavailable. final bool isPhysicalDevice; /// Operating system information derived from `sys/utsname.h`. + /// + /// The value is an empty String if it is not available. final IosUtsname utsname; /// Deserializes from the map message received from [_kChannel]. @@ -73,18 +89,28 @@ class IosUtsname { }); /// Operating system name. + /// + /// The value is an empty String if it is not available. final String sysname; /// Network node name. + /// + /// The value is an empty String if it is not available. final String nodename; /// Release level. + /// + /// The value is an empty String if it is not available. final String release; /// Version level. + /// + /// The value is an empty String if it is not available. final String version; /// Hardware type (e.g. 'iPhone7,1' for iPhone 6 Plus). + /// + /// The value is an empty String if it is not available. final String machine; /// Deserializes from the map message received from [_kChannel]. From 5f4e469c877b09399a1287046a31da27aa71cd9d Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 24 Feb 2021 17:16:40 -0800 Subject: [PATCH 9/9] device_info stable --- packages/device_info/device_info/CHANGELOG.md | 11 ++--------- packages/device_info/device_info/example/pubspec.yaml | 4 ++-- packages/device_info/device_info/pubspec.yaml | 10 +++++----- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/device_info/device_info/CHANGELOG.md b/packages/device_info/device_info/CHANGELOG.md index 910d265b7c3e..f849131eff19 100644 --- a/packages/device_info/device_info/CHANGELOG.md +++ b/packages/device_info/device_info/CHANGELOG.md @@ -1,14 +1,7 @@ -## 2.0.0-nullsafety.2 - -* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) - -## 2.0.0-nullsafety.1 - -* Bump Dart SDK to support null safety. - -## 2.0.0-nullsafety +## 2.0.0 * Migrate to null safety. +* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) ## 1.0.1 diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index 1f636977c2a9..bc7d00ef87f0 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -17,11 +17,11 @@ dev_dependencies: sdk: flutter integration_test: path: ../../../integration_test - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 flutter: uses-material-design: true environment: - sdk: ">=2.10.0-56.0.dev <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/device_info/device_info/pubspec.yaml b/packages/device_info/device_info/pubspec.yaml index bcdc7c8b54d1..0196338223a6 100644 --- a/packages/device_info/device_info/pubspec.yaml +++ b/packages/device_info/device_info/pubspec.yaml @@ -2,7 +2,7 @@ name: device_info description: Flutter plugin providing detailed information about the device (make, model, etc.), and Android or iOS version the app is running on. homepage: https://github.com/flutter/plugins/tree/master/packages/device_info -version: 2.0.0-nullsafety.2 +version: 2.0.0 flutter: plugin: @@ -16,13 +16,13 @@ flutter: dependencies: flutter: sdk: flutter - device_info_platform_interface: ^2.0.0-nullsafety.1 + device_info_platform_interface: ^2.0.0 dev_dependencies: - test: ^1.10.0-nullsafety.1 + test: ^1.16.3 flutter_test: sdk: flutter - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.12.13+hotfix.5"