-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[package_info] Migrate to null safety #3398
Changes from 1 commit
0021bef
c76b56c
3083760
1d7b6fc
08b6bd2
7092d00
d2b1466
a5f22e9
29c6f8b
c28e3fe
9f1af8d
bd08214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| 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+3 | ||
|
|
||
| * Update Flutter SDK constraint. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,30 +24,29 @@ 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; | ||
| return _fromPlatform!; | ||
| } | ||
|
|
||
| final Map<String, dynamic> map = | ||
| final Map<String, dynamic>? map = | ||
| await _kChannel.invokeMapMethod<String, dynamic>('getAll'); | ||
| _fromPlatform = PackageInfo( | ||
| appName: map["appName"], | ||
| return _fromPlatform = PackageInfo( | ||
|
||
| appName: map!["appName"], | ||
|
||
| packageName: map["packageName"], | ||
| version: map["version"], | ||
| buildNumber: map["buildNumber"], | ||
| ); | ||
| return _fromPlatform; | ||
| } | ||
|
|
||
| /// The app name. `CFBundleDisplayName` on iOS, `application/label` on Android. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't need
_fromPlatform!since the analyzer is able to detect the enclosing_fromPlatform != nullcheck.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I was wondering about that too. When I remove it, I get this error
I also made it synchronous just in case that was the problem. It seems like the static analysis is missing the null check. I'm probably missing something obvious, but have you seen this before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah. @mehmetf just pointed out that the variable needs to be defined in the local scope