Skip to content
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

Null safety #211

Merged
merged 10 commits into from Dec 14, 2021
Merged

Null safety #211

merged 10 commits into from Dec 14, 2021

Conversation

lielb100
Copy link
Contributor

@lielb100 lielb100 commented Oct 17, 2021

Upgrade to Flutter SDK 2.12.0 sound null safety

I spent a lot of time and made the whole repo null safe, to make it more modern and future-proof.
Also I linted all the code with these analysis rules:

  rules:
    file_names: false
    constant_identifier_names: false
    avoid_print: false

Suggesting to add a new branch for null_safety, and merge it when it is 100% stable.


Packages

  • - removed flutter_link_preview didn't have a null safe version so I replaced it
  • + added flutter_link_previewer new link preview package
  • + added flutter_chat_types for PreviewData type
  • + added translator for tweet translation

@TheAlphamerc TheAlphamerc self-assigned this Oct 23, 2021
Copy link
Owner

@TheAlphamerc TheAlphamerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lielb100 for making this contribution. You have done a great job. Let me know if you are done with all required changes. Once you done I'll review the PR and let you know if something still needs to be change.

@lielb100
Copy link
Contributor Author

Sorry it talk long, but it's done and ready to be reviewd, I'd be happy to help with further devolopment of the app.

Thanks @lielb100 for making this contribution. You have done a great job. Let me know if you are done with all required changes. Once you done I'll review the PR and let you know if something still needs to be change.

Copy link
Owner

@TheAlphamerc TheAlphamerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lielb100 I have added some comments pls check these.


NotificationModel.fromJson(String tweetId, Map<dynamic, dynamic> map) {
this.id = tweetId;
id = tweetId;
final data = json.decode(json.encode(map["data"])) as Map<String, dynamic>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting below error during app start.

Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

cprint(e, errorIn: "On onMessageOpenedApp");
}
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage? event) {
if (event != null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have of add null check condition for event.data. There are some cases where event.data occured to be null value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event.data is a non nullable String, I don't think it's possible for it to be null.

lib/state/base/tweetBaseState.dart Show resolved Hide resolved
await remoteConfig.fetchAndActivate();
// await remoteConfig.
var data = remoteConfig.getString('FcmServerKey');
if (data != null && data.isNotEmpty) {
if (data.isNotEmpty) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add data null check condition. If FcmServerKey is not available in firebase remote config then it'll retun null value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data is a non nullable String, I don't think it's possible for it to be null.

lib/helper/utility.dart Show resolved Hide resolved
await remoteConfig.fetchAndActivate();
// await remoteConfig.activateFetched();
var data = remoteConfig.getString('appVersion');
if (data != null && data.isNotEmpty) {
if (data.isNotEmpty) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add null check condition for data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data is a non nullable String, I don't think it's possible for it to be null.

lib/ui/page/profile/EditProfilePage.dart Show resolved Hide resolved
Copy link
Owner

@TheAlphamerc TheAlphamerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lielb100 for making this contribution.

@TheAlphamerc TheAlphamerc merged commit 9975573 into TheAlphamerc:master Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants