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

Fixes #11545 - Fix the null safety issue in shimmer example in cookbook #11546

Closed

Conversation

kishan-dhankecha
Copy link

Issues fixed by this PR (if any): #11545

I am not sure if I need to make changes in all the files that I changed or not so I'll keep this change in the Draft until someone corrects me If I made the wrong changes.

Presubmit checklist

  • This PR is marked as draft with an explanation if not meant to land until a future stable release.
  • This PR doesn’t contain automatically generated corrections (Grammarly or similar).
  • This PR follows the Google Developer Documentation Style Guidelines — for example, it doesn’t use i.e. or e.g., and it avoids I and we (first person).
  • This PR uses semantic line breaks of 80 characters or fewer.

@kishan-dhankecha
Copy link
Author

Note that this issue of null check only happens when a user forgets to wrap the widget with Shimmer. In that case, context will not find the Shimmer on the upper side of the tree.

@kishan-dhankecha kishan-dhankecha marked this pull request as ready for review January 7, 2025 12:36
@kishan-dhankecha kishan-dhankecha requested review from sfshaza2, parlough and a team as code owners January 7, 2025 12:36
Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

This isn't correct. Since the "shimmer" variable hasn't been created with a question mark, it cannot be null, so you don't have to test it for null. For more info, see:
https://dart.dev/null-safety/understanding-null-safety

@sfshaza2
Copy link
Contributor

Closing.

@sfshaza2 sfshaza2 closed this Jan 10, 2025
@kishan-dhankecha
Copy link
Author

Note that this issue of null check only happens when a user forgets to wrap the widget with Shimmer. In that case, context will not find the Shimmer on the upper side of the tree.

As said above this issue happens only when the Shimmer widget is not added to the parent stack. For this to work first we have to add Shimmer widget at the top of the widget tree. (Ideally near the MaterialApp). After that to show the actual animation for any widget we will wrap that with ShimmerLoading widget. If somehow the user does not provide the Shimmer widget at the top this thorws a null error.

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.

2 participants