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 issue on the given example! #11545

Open
1 task done
kishan-dhankecha opened this issue Dec 26, 2024 · 0 comments
Open
1 task done

Null Safety issue on the given example! #11545

kishan-dhankecha opened this issue Dec 26, 2024 · 0 comments
Labels
from.page-issue Reported in a reader-filed concern

Comments

@kishan-dhankecha
Copy link

Page URL

https://docs.flutter.dev/cookbook/effects/shimmer-loading/

Page source

https://github.com/flutter/website/tree/main/src/content/cookbook/effects/shimmer-loading.md

Describe the problem

There is an issue with the code provided in the example below. When I copied the whole code from the interactive editor in the website and pasted it into my project to use the ShimmerLoading widget, I found that I get the classic Null check operator used on a null value error. See the issue in the below snippet.

// Collect ancestor shimmer information.
final shimmer = Shimmer.of(context)!; /// Error comes from this line
if (!shimmer.isSized) {
  // The ancestor Shimmer widget isn't laid
  // out yet. Return an empty box.
  return const SizedBox();
}

Expected fix

It should be changed to this,

// Collect ancestor shimmer info.
final shimmer = Shimmer.of(context);
if (shimmer == null || !shimmer.isSized) {
  // The ancestor Shimmer widget has not laid
  // itself out yet. Return an empty box.
  return const SizedBox();
}

Additional context

No response

I would like to fix this problem.

  • I will try and fix this problem on docs.flutter.dev.
@kishan-dhankecha kishan-dhankecha added the from.page-issue Reported in a reader-filed concern label Dec 26, 2024
kishan-dhankecha added a commit to kishan-dhankecha/flutter-website that referenced this issue Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from.page-issue Reported in a reader-filed concern
Projects
None yet
Development

No branches or pull requests

1 participant