Closed san-smith closed 3 years ago
Looks good, going to push a new version do pubdev right away.
Just publisher version 0.1
Thanks!
Unfortunately this introduced some issues (see https://github.com/lschmierer/android_play_install_referrer/issues/11).
I think changing
late final String _installReferrer;
late final int _referrerClickTimestampSeconds;
late final int _installBeginTimestampSeconds;
late final int _referrerClickTimestampServerSeconds;
late final int _installBeginTimestampServerSeconds;
late final String _installVersion;
late final bool _googlePlayInstantParam;
to
late final String? _installReferrer;
late final int? _referrerClickTimestampSeconds;
late final int? _installBeginTimestampSeconds;
late final int? _referrerClickTimestampServerSeconds;
late final int? _installBeginTimestampServerSeconds;
late final String? _installVersion;
late final bool ?_googlePlayInstantParam;
will fix this.
By the way, why was it necessary to the late
keyword?
If you are using nullable types (like String?
), then the late
keyword is not necessary.
But we have to understand, can details
really have null values for these keys?
val details = HashMap<String, Any?>()
details["installReferrer"] = referrerDetails.installReferrer
details["referrerClickTimestampSeconds"] = referrerDetails.referrerClickTimestampSeconds
details["installBeginTimestampSeconds"] = referrerDetails.installBeginTimestampSeconds
details["referrerClickTimestampServerSeconds"] = referrerDetails.referrerClickTimestampServerSeconds
details["installBeginTimestampServerSeconds"] = referrerDetails.installBeginTimestampServerSeconds
details["installVersion"] = referrerDetails.installVersion
details["googlePlayInstantParam"] = referrerDetails.googlePlayInstantParam
If so, it is better to use types with ?
.
By the way, why was it necessary to the
late
keyword?
In short: it can be necessary if we use non nullable type variable without initialization. More you can read about the late keyword in the documentation.
I have changed the two Strings to String?
. ReferrerDetails reads its values from a BaseBundle.
BaseBundle.getString
can return null. getLong
and getBoolean
return default values, so they can not be null.
https://developer.android.com/reference/android/os/BaseBundle
In short: it can be necessary if we use non nullable type variable without initialization.
The non-null variables are initialized in the constructor. I don't see where late initialization is necessary.
Hello! I have added null safety support for the package, this will help migrate projects that use your package to newer flutter versions.