Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[package_info] Migrate to null safety #3398

Merged
merged 12 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/package_info/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0-nullsafety

* Migrate to null safety.

## 0.4.3+4

* Ensure `IntegrationTestPlugin` is registered in `example` app, so Firebase Test Lab tests report test results correctly. [Issue](https://github.com/flutter/flutter/issues/74944).
Expand Down
23 changes: 12 additions & 11 deletions packages/package_info/lib/package_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,31 @@ class PackageInfo {
/// See [fromPlatform] for the right API to get a [PackageInfo] that's
/// actually populated with real data.
PackageInfo({
this.appName,
this.packageName,
this.version,
this.buildNumber,
required this.appName,
required this.packageName,
required this.version,
required this.buildNumber,
});

static PackageInfo _fromPlatform;
static PackageInfo? _fromPlatform;

/// Retrieves package information from the platform.
/// The result is cached.
static Future<PackageInfo> fromPlatform() async {
if (_fromPlatform != null) {
return _fromPlatform;
}
PackageInfo? packageInfo = _fromPlatform;
if (packageInfo != null) return packageInfo;

final Map<String, dynamic> map =
await _kChannel.invokeMapMethod<String, dynamic>('getAll');
_fromPlatform = PackageInfo(
(await _kChannel.invokeMapMethod<String, dynamic>('getAll'))!;

packageInfo = PackageInfo(
appName: map["appName"],
packageName: map["packageName"],
version: map["version"],
buildNumber: map["buildNumber"],
);
return _fromPlatform;
_fromPlatform = packageInfo;
return packageInfo;
}

/// The app name. `CFBundleDisplayName` on iOS, `application/label` on Android.
Expand Down
6 changes: 3 additions & 3 deletions packages/package_info/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/package_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.3+4
version: 0.5.0-nullsafety

flutter:
plugin:
Expand All @@ -29,8 +29,8 @@ dev_dependencies:
sdk: flutter
integration_test:
path: ../integration_test
pedantic: ^1.8.0
pedantic: ^1.10.0-nullsafety

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
2 changes: 1 addition & 1 deletion packages/package_info/test/package_info_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {

const MethodChannel channel =
MethodChannel('plugins.flutter.io/package_info');
List<MethodCall> log;
late List<MethodCall> log;

channel.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
Expand Down
1 change: 1 addition & 0 deletions script/nnbd_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ readonly NNBD_PLUGINS_LIST=(
"google_sign_in"
"local_auth"
"path_provider"
"package_info"
"plugin_platform_interface"
"share"
"shared_preferences"
Expand Down