From 09b2a8cb1ee1bbf40857918157294b399f6206a3 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 12 Oct 2020 12:42:00 -0700 Subject: [PATCH 01/15] migrate device_info_platform_interface --- packages/device_info/device_info/pubspec.yaml | 3 +- .../lib/model/android_device_info.dart | 56 +++++++++---------- .../lib/model/ios_device_info.dart | 26 ++++----- .../pubspec.yaml | 5 +- .../test/method_channel_device_info_test.dart | 2 +- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/packages/device_info/device_info/pubspec.yaml b/packages/device_info/device_info/pubspec.yaml index 967a5bb0b585..1cdd4a4542f6 100644 --- a/packages/device_info/device_info/pubspec.yaml +++ b/packages/device_info/device_info/pubspec.yaml @@ -19,7 +19,8 @@ flutter: dependencies: flutter: sdk: flutter - device_info_platform_interface: ^1.0.0 + device_info_platform_interface: + path: ../device_info_platform_interface dev_dependencies: test: ^1.3.0 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 5b326cc5350a..f10dd9dd64dc 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 @@ -21,57 +21,57 @@ class AndroidDeviceInfo { this.manufacturer, this.model, this.product, - List supported32BitAbis, - List supported64BitAbis, - List supportedAbis, + required List supported32BitAbis, + required List supported64BitAbis, + required List supportedAbis, this.tags, this.type, this.isPhysicalDevice, this.androidId, - List systemFeatures, + required List systemFeatures, }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis), systemFeatures = List.unmodifiable(systemFeatures); /// Android operating system version values derived from `android.os.Build.VERSION`. - final AndroidBuildVersion version; + final AndroidBuildVersion? version; /// The name of the underlying board, like "goldfish". - final String board; + final String? board; /// The system bootloader version number. - final String bootloader; + final String? bootloader; /// The consumer-visible brand with which the product/hardware will be associated, if any. - final String brand; + final String? brand; /// The name of the industrial design. - final String device; + final String? device; /// A build ID string meant for displaying to the user. - final String display; + final String? display; /// A string that uniquely identifies this build. - final String fingerprint; + final String? fingerprint; /// The name of the hardware (from the kernel command line or /proc). - final String hardware; + final String? hardware; /// Hostname. - final String host; + final String? host; /// Either a changelist number, or a label like "M4-rc20". - final String id; + final String? id; /// The manufacturer of the product/hardware. - final String manufacturer; + final String? manufacturer; /// The end-user-visible name for the end product. - final String model; + final String? model; /// The name of the overall product. - final String product; + final String? product; /// An ordered list of 32 bit ABIs supported by this device. final List supported32BitAbis; @@ -83,16 +83,16 @@ class AndroidDeviceInfo { final List supportedAbis; /// Comma-separated tags describing the build, like "unsigned,debug". - final String tags; + final String? tags; /// The type of build, like "user" or "eng". - final String type; + final String? type; /// `false` if the application is running in an emulator, `true` otherwise. - final bool isPhysicalDevice; + final bool? isPhysicalDevice; /// The Android hardware device ID that is unique between the device + user and app signing. - final String androidId; + final String? androidId; /// Describes what features are available on the current device. /// @@ -161,27 +161,27 @@ class AndroidBuildVersion { }); /// The base OS build the product is based on. - final String baseOS; + final String? baseOS; /// The current development codename, or the string "REL" if this is a release build. - final String codename; + final String? codename; /// The internal value used by the underlying source control to represent this build. - final String incremental; + final String? incremental; /// The developer preview revision of a prerelease SDK. - final int previewSdkInt; + final int? previewSdkInt; /// The user-visible version string. - final String release; + 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 - final int sdkInt; + final int? sdkInt; /// The user-visible security patch level. - final String securityPatch; + final String? securityPatch; /// Deserializes from the map message received from [_kChannel]. static AndroidBuildVersion _fromMap(Map map) { 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 d41202492101..44c5410ea896 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,28 +19,28 @@ class IosDeviceInfo { }); /// Device name. - final String name; + final String? name; /// The name of the current operating system. - final String systemName; + final String? systemName; /// The current operating system version. - final String systemVersion; + final String? systemVersion; /// Device model. - final String model; + final String? model; /// Localized name of the device model. - final String localizedModel; + final String? localizedModel; /// Unique UUID value identifying the current device. - final String identifierForVendor; + final String? identifierForVendor; /// `false` if the application is running in a simulator, `true` otherwise. - final bool isPhysicalDevice; + final bool? isPhysicalDevice; /// Operating system information derived from `sys/utsname.h`. - final IosUtsname utsname; + final IosUtsname? utsname; /// Deserializes from the map message received from [_kChannel]. static IosDeviceInfo fromMap(Map map) { @@ -70,19 +70,19 @@ class IosUtsname { }); /// Operating system name. - final String sysname; + final String? sysname; /// Network node name. - final String nodename; + final String? nodename; /// Release level. - final String release; + final String? release; /// Version level. - final String version; + final String? version; /// Hardware type (e.g. 'iPhone7,1' for iPhone 6 Plus). - final String machine; + final String? machine; /// Deserializes from the map message received from [_kChannel]. static IosUtsname _fromMap(Map map) { diff --git a/packages/device_info/device_info_platform_interface/pubspec.yaml b/packages/device_info/device_info_platform_interface/pubspec.yaml index 656e5b24c373..860eed3c95ec 100644 --- a/packages/device_info/device_info_platform_interface/pubspec.yaml +++ b/packages/device_info/device_info_platform_interface/pubspec.yaml @@ -9,7 +9,8 @@ dependencies: flutter: sdk: flutter meta: ^1.1.8 - plugin_platform_interface: ^1.0.2 + plugin_platform_interface: + path: ../../plugin_platform_interface dev_dependencies: flutter_test: @@ -18,5 +19,5 @@ dev_dependencies: pedantic: ^1.8.0 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.10.0-56.0.dev <3.0.0' flutter: ">=1.9.1+hotfix.4 <2.0.0" 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 1da52e2cf39f..dc9fb2c26562 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 @@ -13,7 +13,7 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group("$MethodChannelDeviceInfo", () { - MethodChannelDeviceInfo methodChannelDeviceInfo; + late MethodChannelDeviceInfo methodChannelDeviceInfo; setUp(() async { methodChannelDeviceInfo = MethodChannelDeviceInfo(); From 67e640d048ea4013c6fbecc1b03cca8667b8572e Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 12 Oct 2020 13:39:05 -0700 Subject: [PATCH 02/15] fixes --- .../device_info_platform_interface/CHANGELOG.md | 4 ++++ .../lib/model/android_device_info.dart | 8 ++++---- .../device_info_platform_interface/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/CHANGELOG.md b/packages/device_info/device_info_platform_interface/CHANGELOG.md index 8a7eb6c46be3..0e7e24e7cf11 100644 --- a/packages/device_info/device_info_platform_interface/CHANGELOG.md +++ b/packages/device_info/device_info_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +- Support NNBD. + ## 1.0.1 - Documentation typo fixed. 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 f10dd9dd64dc..09efa58c6847 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 @@ -21,14 +21,14 @@ class AndroidDeviceInfo { this.manufacturer, this.model, this.product, - required List supported32BitAbis, - required List supported64BitAbis, - required List supportedAbis, + List supported32BitAbis = const [], + List supported64BitAbis = const [], + List supportedAbis = const [], this.tags, this.type, this.isPhysicalDevice, this.androidId, - required List systemFeatures, + List systemFeatures = const [], }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis), diff --git a/packages/device_info/device_info_platform_interface/pubspec.yaml b/packages/device_info/device_info_platform_interface/pubspec.yaml index 860eed3c95ec..f043b4e2b274 100644 --- a/packages/device_info/device_info_platform_interface/pubspec.yaml +++ b/packages/device_info/device_info_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ 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: 1.0.1 +version: 2.0.1 dependencies: flutter: From 9ed7d172f2f2261e2e15bb9250d2f04c24fdefb7 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 12 Oct 2020 13:40:36 -0700 Subject: [PATCH 03/15] update version --- .../device_info/device_info_platform_interface/CHANGELOG.md | 4 ++-- .../device_info/device_info_platform_interface/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/device_info/device_info_platform_interface/CHANGELOG.md b/packages/device_info/device_info_platform_interface/CHANGELOG.md index 0e7e24e7cf11..f48c0a9cee21 100644 --- a/packages/device_info/device_info_platform_interface/CHANGELOG.md +++ b/packages/device_info/device_info_platform_interface/CHANGELOG.md @@ -1,6 +1,6 @@ -## 2.0.1 +## 1.1.0-nullsafety -- Support NNBD. +* Migrate to null safety. ## 1.0.1 diff --git a/packages/device_info/device_info_platform_interface/pubspec.yaml b/packages/device_info/device_info_platform_interface/pubspec.yaml index f043b4e2b274..3854598cf320 100644 --- a/packages/device_info/device_info_platform_interface/pubspec.yaml +++ b/packages/device_info/device_info_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ 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.1 +version: 1.1.0 dependencies: flutter: From b9491baf5eb633bfda0ed0caa51b3d1003eddad0 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 12 Oct 2020 15:41:15 -0700 Subject: [PATCH 04/15] migrate device info --- packages/device_info/device_info/CHANGELOG.md | 4 +++ .../device_info/example/lib/main.dart | 26 +++++++++---------- .../device_info/example/pubspec.yaml | 6 ++++- .../device_info/lib/device_info.dart | 4 +-- packages/device_info/device_info/pubspec.yaml | 11 +++++--- .../pubspec.yaml | 11 +++++--- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/packages/device_info/device_info/CHANGELOG.md b/packages/device_info/device_info/CHANGELOG.md index 9e627f90b30f..d93f93a4af8f 100644 --- a/packages/device_info/device_info/CHANGELOG.md +++ b/packages/device_info/device_info/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.0-nullsafety + +* Migrate to null safety. + ## 0.4.2+8 * Keep handling deprecated Android v1 classes for backward compatibility. diff --git a/packages/device_info/device_info/example/lib/main.dart b/packages/device_info/device_info/example/lib/main.dart index 1c1064aa09ee..b6ab74e0812c 100644 --- a/packages/device_info/device_info/example/lib/main.dart +++ b/packages/device_info/device_info/example/lib/main.dart @@ -36,7 +36,7 @@ class _MyAppState extends State { } Future initPlatformState() async { - Map deviceData; + Map deviceData = {}; try { if (Platform.isAndroid) { @@ -59,13 +59,13 @@ class _MyAppState extends State { Map _readAndroidBuildData(AndroidDeviceInfo build) { return { - 'version.securityPatch': build.version.securityPatch, - 'version.sdkInt': build.version.sdkInt, - 'version.release': build.version.release, - 'version.previewSdkInt': build.version.previewSdkInt, - 'version.incremental': build.version.incremental, - 'version.codename': build.version.codename, - 'version.baseOS': build.version.baseOS, + 'version.securityPatch': build.version?.securityPatch, + 'version.sdkInt': build.version?.sdkInt, + 'version.release': build.version?.release, + 'version.previewSdkInt': build.version?.previewSdkInt, + 'version.incremental': build.version?.incremental, + 'version.codename': build.version?.codename, + 'version.baseOS': build.version?.baseOS, 'board': build.board, 'bootloader': build.bootloader, 'brand': build.brand, @@ -98,11 +98,11 @@ class _MyAppState extends State { 'localizedModel': data.localizedModel, 'identifierForVendor': data.identifierForVendor, 'isPhysicalDevice': data.isPhysicalDevice, - 'utsname.sysname:': data.utsname.sysname, - 'utsname.nodename:': data.utsname.nodename, - 'utsname.release:': data.utsname.release, - 'utsname.version:': data.utsname.version, - 'utsname.machine:': data.utsname.machine, + 'utsname.sysname:': data.utsname?.sysname, + 'utsname.nodename:': data.utsname?.nodename, + 'utsname.release:': data.utsname?.release, + 'utsname.version:': data.utsname?.version, + 'utsname.machine:': data.utsname?.machine, }; } diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index e22f6026ba69..11222367703a 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -12,7 +12,11 @@ dev_dependencies: sdk: flutter integration_test: path: ../../../integration_test - pedantic: ^1.8.0 + pedantic: ^1.10.0-nullsafety.1 flutter: uses-material-design: true + +environment: + sdk: '>=2.10.0-56.0.dev <3.0.0' + \ No newline at end of file diff --git a/packages/device_info/device_info/lib/device_info.dart b/packages/device_info/device_info/lib/device_info.dart index f63730c4323f..bccc3d2fbfa6 100644 --- a/packages/device_info/device_info/lib/device_info.dart +++ b/packages/device_info/device_info/lib/device_info.dart @@ -15,7 +15,7 @@ class DeviceInfoPlugin { DeviceInfoPlugin(); /// This information does not change from call to call. Cache it. - AndroidDeviceInfo _cachedAndroidDeviceInfo; + AndroidDeviceInfo? _cachedAndroidDeviceInfo; /// Information derived from `android.os.Build`. /// @@ -25,7 +25,7 @@ class DeviceInfoPlugin { await DeviceInfoPlatform.instance.androidInfo(); /// This information does not change from call to call. Cache it. - IosDeviceInfo _cachedIosDeviceInfo; + IosDeviceInfo? _cachedIosDeviceInfo; /// Information derived from `UIDevice`. /// diff --git a/packages/device_info/device_info/pubspec.yaml b/packages/device_info/device_info/pubspec.yaml index 1cdd4a4542f6..473d079a0e4f 100644 --- a/packages/device_info/device_info/pubspec.yaml +++ b/packages/device_info/device_info/pubspec.yaml @@ -5,7 +5,10 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/device_info # 0.4.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 0.4.2+8 +version: 0.5.0-nullsafety + +# Don't publish this package until null safety is stable or the package is in the allow list. +publish_to: none flutter: plugin: @@ -23,11 +26,11 @@ dependencies: path: ../device_info_platform_interface dev_dependencies: - test: ^1.3.0 + test: ^1.10.0-nullsafety.1 flutter_test: sdk: flutter - pedantic: ^1.8.0 + pedantic: ^1.10.0-nullsafety.1 environment: - sdk: ">=2.1.0<3.0.0" + sdk: '>=2.10.0-56.0.dev <3.0.0' flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/packages/device_info/device_info_platform_interface/pubspec.yaml b/packages/device_info/device_info_platform_interface/pubspec.yaml index 3854598cf320..54ab561c87ec 100644 --- a/packages/device_info/device_info_platform_interface/pubspec.yaml +++ b/packages/device_info/device_info_platform_interface/pubspec.yaml @@ -3,20 +3,23 @@ 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: 1.1.0 +version: 1.1.0-nullsafety + +# Don't publish this package until null safety is stable or the package is in the allow list. +publish_to: none dependencies: flutter: sdk: flutter - meta: ^1.1.8 + meta: ^1.3.0-nullsafety.3 plugin_platform_interface: path: ../../plugin_platform_interface dev_dependencies: flutter_test: sdk: flutter - mockito: ^4.1.1 - pedantic: ^1.8.0 + test: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0-nullsafety.1 environment: sdk: '>=2.10.0-56.0.dev <3.0.0' From 663e074b41c630ea666eaf1eaf6ec498f1ef0375 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 14 Oct 2020 09:27:54 -0700 Subject: [PATCH 05/15] more fix --- .../example/integration_test/device_info_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/device_info/device_info/example/integration_test/device_info_test.dart b/packages/device_info/device_info/example/integration_test/device_info_test.dart index 2fd1d9a9a491..6022d7fc3e69 100644 --- a/packages/device_info/device_info/example/integration_test/device_info_test.dart +++ b/packages/device_info/device_info/example/integration_test/device_info_test.dart @@ -10,8 +10,8 @@ import 'package:integration_test/integration_test.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - IosDeviceInfo iosInfo; - AndroidDeviceInfo androidInfo; + IosDeviceInfo? iosInfo; + AndroidDeviceInfo? androidInfo; setUpAll(() async { final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); @@ -24,9 +24,9 @@ void main() { testWidgets('Can get non-null device model', (WidgetTester tester) async { if (Platform.isIOS) { - expect(iosInfo.model, isNotNull); + expect(iosInfo?.model, isNotNull); } else if (Platform.isAndroid) { - expect(androidInfo.model, isNotNull); + expect(androidInfo?.model, isNotNull); } }); } From 3dfbb266d9d92397fb4a195f8b3e2cb6e95a2416 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 10:20:45 -0700 Subject: [PATCH 06/15] review --- .../device_info/example/lib/main.dart | 24 ++--- .../device_info/example/pubspec.yaml | 1 - .../lib/model/android_device_info.dart | 94 +++++++++---------- .../lib/model/ios_device_info.dart | 48 +++++----- 4 files changed, 83 insertions(+), 84 deletions(-) diff --git a/packages/device_info/device_info/example/lib/main.dart b/packages/device_info/device_info/example/lib/main.dart index b6ab74e0812c..3aded93809b3 100644 --- a/packages/device_info/device_info/example/lib/main.dart +++ b/packages/device_info/device_info/example/lib/main.dart @@ -59,13 +59,13 @@ class _MyAppState extends State { Map _readAndroidBuildData(AndroidDeviceInfo build) { return { - 'version.securityPatch': build.version?.securityPatch, - 'version.sdkInt': build.version?.sdkInt, - 'version.release': build.version?.release, - 'version.previewSdkInt': build.version?.previewSdkInt, - 'version.incremental': build.version?.incremental, - 'version.codename': build.version?.codename, - 'version.baseOS': build.version?.baseOS, + 'version.securityPatch': build.version.securityPatch, + 'version.sdkInt': build.version.sdkInt, + 'version.release': build.version.release, + 'version.previewSdkInt': build.version.previewSdkInt, + 'version.incremental': build.version.incremental, + 'version.codename': build.version.codename, + 'version.baseOS': build.version.baseOS, 'board': build.board, 'bootloader': build.bootloader, 'brand': build.brand, @@ -98,11 +98,11 @@ class _MyAppState extends State { 'localizedModel': data.localizedModel, 'identifierForVendor': data.identifierForVendor, 'isPhysicalDevice': data.isPhysicalDevice, - 'utsname.sysname:': data.utsname?.sysname, - 'utsname.nodename:': data.utsname?.nodename, - 'utsname.release:': data.utsname?.release, - 'utsname.version:': data.utsname?.version, - 'utsname.machine:': data.utsname?.machine, + 'utsname.sysname:': data.utsname.sysname, + 'utsname.nodename:': data.utsname.nodename, + 'utsname.release:': data.utsname.release, + 'utsname.version:': data.utsname.version, + 'utsname.machine:': data.utsname.machine, }; } diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index 11222367703a..9a9556ab5543 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -19,4 +19,3 @@ flutter: environment: sdk: '>=2.10.0-56.0.dev <3.0.0' - \ No newline at end of file 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 09efa58c6847..ba63ec2536d1 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 @@ -35,43 +35,43 @@ class AndroidDeviceInfo { systemFeatures = List.unmodifiable(systemFeatures); /// Android operating system version values derived from `android.os.Build.VERSION`. - final AndroidBuildVersion? version; + final AndroidBuildVersion version; /// The name of the underlying board, like "goldfish". - final String? board; + final String board; /// The system bootloader version number. - final String? bootloader; + final String bootloader; /// The consumer-visible brand with which the product/hardware will be associated, if any. - final String? brand; + final String brand; /// The name of the industrial design. - final String? device; + final String device; /// A build ID string meant for displaying to the user. - final String? display; + final String display; /// A string that uniquely identifies this build. - final String? fingerprint; + final String fingerprint; /// The name of the hardware (from the kernel command line or /proc). - final String? hardware; + final String hardware; /// Hostname. - final String? host; + final String host; /// Either a changelist number, or a label like "M4-rc20". - final String? id; + final String id; /// The manufacturer of the product/hardware. - final String? manufacturer; + final String manufacturer; /// The end-user-visible name for the end product. - final String? model; + final String model; /// The name of the overall product. - final String? product; + final String product; /// An ordered list of 32 bit ABIs supported by this device. final List supported32BitAbis; @@ -83,16 +83,16 @@ class AndroidDeviceInfo { final List supportedAbis; /// Comma-separated tags describing the build, like "unsigned,debug". - final String? tags; + final String tags; /// The type of build, like "user" or "eng". - final String? type; + final String type; /// `false` if the application is running in an emulator, `true` otherwise. - final bool? isPhysicalDevice; + final bool isPhysicalDevice; /// The Android hardware device ID that is unique between the device + user and app signing. - final String? androidId; + final String androidId; /// Describes what features are available on the current device. /// @@ -115,25 +115,25 @@ class AndroidDeviceInfo { 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'], + 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'], + tags: map['tags'] ?? '', + type: map['type'] ?? '', + isPhysicalDevice: map['isPhysicalDevice'] ?? '', + androidId: map['androidId'] ?? '', systemFeatures: _fromList(map['systemFeatures'] ?? []), ); } @@ -161,38 +161,38 @@ class AndroidBuildVersion { }); /// The base OS build the product is based on. - final String? baseOS; + final String baseOS; /// The current development codename, or the string "REL" if this is a release build. - final String? codename; + final String codename; /// The internal value used by the underlying source control to represent this build. - final String? incremental; + final String incremental; /// The developer preview revision of a prerelease SDK. - final int? previewSdkInt; + final int previewSdkInt; /// The user-visible version string. - final String? release; + 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 - final int? sdkInt; + final int sdkInt; /// The user-visible security patch level. - final String? securityPatch; + final String securityPatch; /// Deserializes from the map message received from [_kChannel]. static AndroidBuildVersion _fromMap(Map map) { return AndroidBuildVersion._( - baseOS: map['baseOS'], - codename: map['codename'], - incremental: map['incremental'], - previewSdkInt: map['previewSdkInt'], - release: map['release'], - sdkInt: map['sdkInt'], - securityPatch: map['securityPatch'], + baseOS: map['baseOS'] ?? '', + codename: map['codename'] ?? '', + incremental: map['incremental'] ?? '', + previewSdkInt: map['previewSdkInt'] ?? '', + release: map['release'] ?? '', + sdkInt: map['sdkInt'] ?? '', + securityPatch: map['securityPatch'] ?? '', ); } } 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 44c5410ea896..f8b6cb940745 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,38 +19,38 @@ class IosDeviceInfo { }); /// Device name. - final String? name; + final String name; /// The name of the current operating system. - final String? systemName; + final String systemName; /// The current operating system version. - final String? systemVersion; + final String systemVersion; /// Device model. - final String? model; + final String model; /// Localized name of the device model. - final String? localizedModel; + final String localizedModel; /// Unique UUID value identifying the current device. - final String? identifierForVendor; + final String identifierForVendor; /// `false` if the application is running in a simulator, `true` otherwise. - final bool? isPhysicalDevice; + final bool isPhysicalDevice; /// Operating system information derived from `sys/utsname.h`. - final IosUtsname? utsname; + final IosUtsname utsname; /// 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'], + 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() ?? {}), @@ -70,28 +70,28 @@ class IosUtsname { }); /// Operating system name. - final String? sysname; + final String sysname; /// Network node name. - final String? nodename; + final String nodename; /// Release level. - final String? release; + final String release; /// Version level. - final String? version; + final String version; /// Hardware type (e.g. 'iPhone7,1' for iPhone 6 Plus). - final String? machine; + final String machine; /// 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'] ?? '', ); } } From c9c8193bf04d6bbed5215ff2b75b8c1c4bf6b4c3 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 10:59:26 -0700 Subject: [PATCH 07/15] review --- .../lib/model/android_device_info.dart | 56 +++++++++---------- .../lib/model/ios_device_info.dart | 26 ++++----- 2 files changed, 41 insertions(+), 41 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 ba63ec2536d1..6c68b22b52e9 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 @@ -8,27 +8,27 @@ class AndroidDeviceInfo { /// Android device Info class. AndroidDeviceInfo({ - this.version, - this.board, - this.bootloader, - this.brand, - this.device, - this.display, - this.fingerprint, - this.hardware, - this.host, - this.id, - this.manufacturer, - this.model, - this.product, - List supported32BitAbis = const [], - List supported64BitAbis = const [], - List supportedAbis = const [], - this.tags, - this.type, - this.isPhysicalDevice, - this.androidId, - List systemFeatures = const [], + required this.version, + required this.board, + required this.bootloader, + required this.brand, + required this.device, + required this.display, + required this.fingerprint, + required this.hardware, + required this.host, + required this.id, + required this.manufacturer, + required this.model, + required this.product, + required List supported32BitAbis, + required List supported64BitAbis, + required List supportedAbis, + required this.tags, + required this.type, + required this.isPhysicalDevice, + required this.androidId, + required List systemFeatures, }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis), @@ -151,13 +151,13 @@ class AndroidDeviceInfo { /// See: https://developer.android.com/reference/android/os/Build.VERSION.html class AndroidBuildVersion { AndroidBuildVersion._({ - this.baseOS, - this.codename, - this.incremental, - this.previewSdkInt, - this.release, - this.sdkInt, - this.securityPatch, + required this.baseOS, + required this.codename, + required this.incremental, + required this.previewSdkInt, + required this.release, + required this.sdkInt, + required this.securityPatch, }); /// The base OS build the product is based on. 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 f8b6cb940745..f909fadd20ae 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 @@ -8,14 +8,14 @@ class IosDeviceInfo { /// IOS device info class. IosDeviceInfo({ - this.name, - this.systemName, - this.systemVersion, - this.model, - this.localizedModel, - this.identifierForVendor, - this.isPhysicalDevice, - this.utsname, + required this.name, + required this.systemName, + required this.systemVersion, + required this.model, + required this.localizedModel, + required this.identifierForVendor, + required this.isPhysicalDevice, + required this.utsname, }); /// Device name. @@ -62,11 +62,11 @@ class IosDeviceInfo { /// See http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html for details. class IosUtsname { IosUtsname._({ - this.sysname, - this.nodename, - this.release, - this.version, - this.machine, + required this.sysname, + required this.nodename, + required this.release, + required this.version, + required this.machine, }); /// Operating system name. From 628bc38b53f5eeb42a257a0e31660caaa6c3520a Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 11:34:16 -0700 Subject: [PATCH 08/15] format --- .../lib/model/android_device_info.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6c68b22b52e9..242a73361078 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 @@ -29,7 +29,7 @@ class AndroidDeviceInfo { required this.isPhysicalDevice, required this.androidId, required List systemFeatures, - }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), + }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis), systemFeatures = List.unmodifiable(systemFeatures); From 5eaebe81d90f67a0b57e99b141bc65e4795b9274 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 13:50:31 -0700 Subject: [PATCH 09/15] enable nnbd check for device info --- packages/device_info/device_info/analysis_options.yaml | 4 ++++ .../device_info_platform_interface/analysis_options.yaml | 4 ++++ script/incremental_build.sh | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 packages/device_info/device_info/analysis_options.yaml create mode 100644 packages/device_info/device_info_platform_interface/analysis_options.yaml diff --git a/packages/device_info/device_info/analysis_options.yaml b/packages/device_info/device_info/analysis_options.yaml new file mode 100644 index 000000000000..32ff54f2748c --- /dev/null +++ b/packages/device_info/device_info/analysis_options.yaml @@ -0,0 +1,4 @@ +include: ../../../analysis_options.yaml +analyzer: + enable-experiment: + - non-nullable \ No newline at end of file diff --git a/packages/device_info/device_info_platform_interface/analysis_options.yaml b/packages/device_info/device_info_platform_interface/analysis_options.yaml new file mode 100644 index 000000000000..32ff54f2748c --- /dev/null +++ b/packages/device_info/device_info_platform_interface/analysis_options.yaml @@ -0,0 +1,4 @@ +include: ../../../analysis_options.yaml +analyzer: + enable-experiment: + - non-nullable \ No newline at end of file diff --git a/script/incremental_build.sh b/script/incremental_build.sh index c435674b7109..310987294072 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -26,6 +26,8 @@ CUSTOM_ANALYSIS_PLUGINS=( "video_player/video_player_web" "google_maps_flutter/google_maps_flutter_web" "url_launcher/url_launcher_platform_interface" + "device_info/devie_info_platform_interface" + "device_info/device_info" ) # Comma-separated string of the list above readonly CUSTOM_FLAG=$(IFS=, ; echo "${CUSTOM_ANALYSIS_PLUGINS[*]}") From fb7648e38575659f90805bb434653769e8359bbc Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 14:04:30 -0700 Subject: [PATCH 10/15] opt out of nnbd in test --- .../lib/model/android_device_info.dart | 6 +++--- .../test/method_channel_device_info_test.dart | 4 +++- 2 files changed, 6 insertions(+), 4 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 242a73361078..ea5839da14d3 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 @@ -132,7 +132,7 @@ class AndroidDeviceInfo { supportedAbis: _fromList(map['supportedAbis'] ?? []), tags: map['tags'] ?? '', type: map['type'] ?? '', - isPhysicalDevice: map['isPhysicalDevice'] ?? '', + isPhysicalDevice: map['isPhysicalDevice'] ?? false, androidId: map['androidId'] ?? '', systemFeatures: _fromList(map['systemFeatures'] ?? []), ); @@ -189,9 +189,9 @@ class AndroidBuildVersion { baseOS: map['baseOS'] ?? '', codename: map['codename'] ?? '', incremental: map['incremental'] ?? '', - previewSdkInt: map['previewSdkInt'] ?? '', + previewSdkInt: map['previewSdkInt'] ?? 0, release: map['release'] ?? '', - sdkInt: map['sdkInt'] ?? '', + sdkInt: map['sdkInt'] ?? 0, securityPatch: map['securityPatch'] ?? '', ); } 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 dc9fb2c26562..dfc833da7e79 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 @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(cyanglaz): Remove once https://github.com/flutter/flutter/issues/59879 is fixed. +// @dart = 2.9 import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -13,7 +15,7 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group("$MethodChannelDeviceInfo", () { - late MethodChannelDeviceInfo methodChannelDeviceInfo; + MethodChannelDeviceInfo methodChannelDeviceInfo; setUp(() async { methodChannelDeviceInfo = MethodChannelDeviceInfo(); From e7f58b61238a58dc1b439b4da850ab2f83fccb15 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 18:07:26 -0700 Subject: [PATCH 11/15] fix --- script/incremental_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/incremental_build.sh b/script/incremental_build.sh index 310987294072..9dc97a2e3d9c 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -26,7 +26,7 @@ CUSTOM_ANALYSIS_PLUGINS=( "video_player/video_player_web" "google_maps_flutter/google_maps_flutter_web" "url_launcher/url_launcher_platform_interface" - "device_info/devie_info_platform_interface" + "device_info/device_info_platform_interface" "device_info/device_info" ) # Comma-separated string of the list above From 13e96c1bf31792b82fce06d91025c1ad127d62d2 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 19:24:31 -0700 Subject: [PATCH 12/15] fix integaration_test dep --- .../device_info/example/integration_test/device_info_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/device_info/device_info/example/integration_test/device_info_test.dart b/packages/device_info/device_info/example/integration_test/device_info_test.dart index 6022d7fc3e69..1f36f1877aea 100644 --- a/packages/device_info/device_info/example/integration_test/device_info_test.dart +++ b/packages/device_info/device_info/example/integration_test/device_info_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed. +// @dart = 2.9 import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:device_info/device_info.dart'; From 99f6c537fe4464246a916afdeed310409e3c4e8f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 15 Oct 2020 20:51:44 -0700 Subject: [PATCH 13/15] formmat --- .../example/integration_test/device_info_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/device_info/device_info/example/integration_test/device_info_test.dart b/packages/device_info/device_info/example/integration_test/device_info_test.dart index 1f36f1877aea..33b745af13f9 100644 --- a/packages/device_info/device_info/example/integration_test/device_info_test.dart +++ b/packages/device_info/device_info/example/integration_test/device_info_test.dart @@ -12,8 +12,8 @@ import 'package:integration_test/integration_test.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - IosDeviceInfo? iosInfo; - AndroidDeviceInfo? androidInfo; + IosDeviceInfo iosInfo; + AndroidDeviceInfo androidInfo; setUpAll(() async { final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); @@ -26,9 +26,9 @@ void main() { testWidgets('Can get non-null device model', (WidgetTester tester) async { if (Platform.isIOS) { - expect(iosInfo?.model, isNotNull); + expect(iosInfo.model, isNotNull); } else if (Platform.isAndroid) { - expect(androidInfo?.model, isNotNull); + expect(androidInfo.model, isNotNull); } }); } From b4f0af245127e50f0d464112943c596e111fef1b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 16 Oct 2020 11:30:25 -0700 Subject: [PATCH 14/15] Update analysis_options.yaml --- packages/device_info/device_info/analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/device_info/device_info/analysis_options.yaml b/packages/device_info/device_info/analysis_options.yaml index 32ff54f2748c..3d64bb57fe49 100644 --- a/packages/device_info/device_info/analysis_options.yaml +++ b/packages/device_info/device_info/analysis_options.yaml @@ -1,4 +1,4 @@ include: ../../../analysis_options.yaml analyzer: enable-experiment: - - non-nullable \ No newline at end of file + - non-nullable From 4844b5250c7bfe22846c07eb9529d74abc778006 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 16 Oct 2020 12:08:39 -0700 Subject: [PATCH 15/15] dart 2.9 for drive --- .../device_info/example/test_driver/integration_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/device_info/device_info/example/test_driver/integration_test.dart b/packages/device_info/device_info/example/test_driver/integration_test.dart index 7a2c21338786..bd3dc09c190c 100644 --- a/packages/device_info/device_info/example/test_driver/integration_test.dart +++ b/packages/device_info/device_info/example/test_driver/integration_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// TODO(cyanglaz): Remove once https://github.com/flutter/flutter/issues/59879 is fixed. +// @dart = 2.9 import 'dart:async'; import 'dart:convert'; import 'dart:io';