Skip to content

Commit 60fa979

Browse files
[package_info] Migrate to null safety (flutter#3398)
1 parent 9e982cf commit 60fa979

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

packages/package_info/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0-nullsafety
2+
3+
* Migrate to null safety.
4+
15
## 0.4.3+4
26

37
* Ensure `IntegrationTestPlugin` is registered in `example` app, so Firebase Test Lab tests report test results correctly. [Issue](https://github.com/flutter/flutter/issues/74944).

packages/package_info/lib/package_info.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,31 @@ class PackageInfo {
2424
/// See [fromPlatform] for the right API to get a [PackageInfo] that's
2525
/// actually populated with real data.
2626
PackageInfo({
27-
this.appName,
28-
this.packageName,
29-
this.version,
30-
this.buildNumber,
27+
required this.appName,
28+
required this.packageName,
29+
required this.version,
30+
required this.buildNumber,
3131
});
3232

33-
static PackageInfo _fromPlatform;
33+
static PackageInfo? _fromPlatform;
3434

3535
/// Retrieves package information from the platform.
3636
/// The result is cached.
3737
static Future<PackageInfo> fromPlatform() async {
38-
if (_fromPlatform != null) {
39-
return _fromPlatform;
40-
}
38+
PackageInfo? packageInfo = _fromPlatform;
39+
if (packageInfo != null) return packageInfo;
4140

4241
final Map<String, dynamic> map =
43-
await _kChannel.invokeMapMethod<String, dynamic>('getAll');
44-
_fromPlatform = PackageInfo(
42+
(await _kChannel.invokeMapMethod<String, dynamic>('getAll'))!;
43+
44+
packageInfo = PackageInfo(
4545
appName: map["appName"],
4646
packageName: map["packageName"],
4747
version: map["version"],
4848
buildNumber: map["buildNumber"],
4949
);
50-
return _fromPlatform;
50+
_fromPlatform = packageInfo;
51+
return packageInfo;
5152
}
5253

5354
/// The app name. `CFBundleDisplayName` on iOS, `application/label` on Android.

packages/package_info/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/package_info
55
# 0.4.y+z is compatible with 1.0.0, if you land a breaking change bump
66
# the version to 2.0.0.
77
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
8-
version: 0.4.3+4
8+
version: 0.5.0-nullsafety
99

1010
flutter:
1111
plugin:
@@ -29,8 +29,8 @@ dev_dependencies:
2929
sdk: flutter
3030
integration_test:
3131
path: ../integration_test
32-
pedantic: ^1.8.0
32+
pedantic: ^1.10.0-nullsafety
3333

3434
environment:
35-
sdk: ">=2.1.0 <3.0.0"
35+
sdk: ">=2.12.0-0 <3.0.0"
3636
flutter: ">=1.12.13+hotfix.5"

packages/package_info/test/package_info_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void main() {
1111

1212
const MethodChannel channel =
1313
MethodChannel('plugins.flutter.io/package_info');
14-
List<MethodCall> log;
14+
late List<MethodCall> log;
1515

1616
channel.setMockMethodCallHandler((MethodCall methodCall) async {
1717
log.add(methodCall);

script/nnbd_plugins.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ readonly NNBD_PLUGINS_LIST=(
1515
"google_sign_in"
1616
"local_auth"
1717
"path_provider"
18+
"package_info"
1819
"plugin_platform_interface"
1920
"share"
2021
"shared_preferences"

0 commit comments

Comments
 (0)