-
Notifications
You must be signed in to change notification settings - Fork 51
Null safety refactor #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -5,17 +5,20 @@ class ErrorMaterialAlert extends StatelessWidget { | |||
final String description; | |||
|
|||
ErrorMaterialAlert({ | |||
@required this.appName, | |||
@required this.description, | |||
required this.appName, |
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.
instead of @required
null safety supports required
@@ -100,7 +100,7 @@ class NativeUpdater { | |||
try { | |||
AppUpdateInfo _updateInfo = await InAppUpdate.checkForUpdate(); | |||
|
|||
if (_updateInfo?.updateAvailable == true) { | |||
if (_updateInfo.updateAvailability == UpdateAvailability.updateAvailable) { |
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.
AppUpdateInfo
in in_app_update 2.0.0
has no longer boolean updateAvailable attribute. it now has updateAvailability attribute which as int. and its can have 4 values
class UpdateAvailability {
UpdateAvailability._();
static int get unknown => 0;
static int get updateNotAvailable => 1;
static int get updateAvailable => 2;
static int get developerTriggeredUpdateInProgress => 3;
}
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.
child: Text('CLOSE'), | ||
color: Colors.green, | ||
textColor: Colors.white, | ||
final ButtonStyle flatButtonStyle = TextButton.styleFrom( |
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.
migrating to TextButton as FlatButtons are now deprecated.
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.
String _iOSCloseButtonLabel; | ||
String _iOSIgnoreButtonLabel; | ||
String _iOSAlertTitle; | ||
late BuildContext _context; |
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.
_context
, _forceUpdate
, _appName
will always be initialized to not null value. but since we want to have singleTon in the static context, we can initialize them at the start. For more https://dart.dev/null-safety/understanding-null-safety#late-variables
late BuildContext _context; | ||
late bool _forceUpdate; | ||
late String _appName; | ||
String? _appStoreUrl; |
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.
since an app can provide either of the android/ios setting hence these attributes can be null. Hence making them optional is a better choice.
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
/// Set up the Buttons | ||
Widget closeAppButton = FlatButton( | ||
Widget closeAppButton = TextButton( |
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.
as Flatbuttons are deprecated migrating them to TextButtons.
@@ -2,21 +2,21 @@ name: native_updater | |||
description: Flutter package for prompting users to update with a native dialog whether using the app store version or any version at the user's discretion. | |||
author: Ofload <tech@ofload.com> | |||
|
|||
version: 0.0.4 | |||
version: 0.0.5 |
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.
bumping version
homepage: https://github.com/loadsmileau/native_updater | ||
|
||
environment: | ||
sdk: ">=2.1.0 <3.0.0" | ||
sdk: '>=2.12.0 <3.0.0' |
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.
migrating to null safety sdk version
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
# package_info will help us to find current installed version of application. | ||
package_info: ^0.4.0+16 | ||
package_info: ^2.0.0 |
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.
migrating to latest version
This also fixes #16 |
@nischalkumar thank you very much for your contribution. Super duper explanations here 🎉 🤗 In the future, try to add this in the commit message itself so anyone can read it without having to come back to the PR. I'm very happy with your changes and will merge the PR. |
This pr contains 3 commits:
Why are the changes done:
Flutter 2.0 has introduced null safety, Now every new version of popular libraries(firebase, http, e.t.c.) recent releases only support null safety and now support for Flutter1.0 is getting thinner. Any flutter project has now to choose either to embrace completely null safety or stay with stale packages(missing out latest fixes and features). Having best of both world is now very tiresome.
For more: understanding null safety
Now The projects who have migrated to null safety or started with null safety can not use native_updator as it has no null safety version. People like these( i recently migrated my project to null safety as I wanted to update firebase dependencies for which null safety is a must) have no choice other than moving out of native_updator.
With flutter 2.0 FlatButtons got deprecated in favour of TextButtons FlatButtons