From db6fa0b5cb61421a1fa0f06a0cf087041f2a7e8a Mon Sep 17 00:00:00 2001 From: Antonin GAVREL Date: Wed, 31 Jan 2024 03:31:11 -0500 Subject: [PATCH] Null safety for Shimmer effect (#10071) --- .../cookbook/effects/shimmer_loading/lib/original_example.dart | 3 ++- src/cookbook/effects/shimmer-loading.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/cookbook/effects/shimmer_loading/lib/original_example.dart b/examples/cookbook/effects/shimmer_loading/lib/original_example.dart index 40925b1418..9ac8a8c810 100644 --- a/examples/cookbook/effects/shimmer_loading/lib/original_example.dart +++ b/examples/cookbook/effects/shimmer_loading/lib/original_example.dart @@ -156,7 +156,8 @@ class ShimmerState extends State with SingleTickerProviderStateMixin { ); // #enddocregion LinearGradient - bool get isSized => (context.findRenderObject() as RenderBox).hasSize; + bool get isSized => + (context.findRenderObject() as RenderBox?)?.hasSize ?? false; Size get size => (context.findRenderObject() as RenderBox).size; diff --git a/src/cookbook/effects/shimmer-loading.md b/src/cookbook/effects/shimmer-loading.md index a9849fc162..a63e3f5cd9 100644 --- a/src/cookbook/effects/shimmer-loading.md +++ b/src/cookbook/effects/shimmer-loading.md @@ -732,7 +732,8 @@ class ShimmerState extends State with SingleTickerProviderStateMixin { _SlidingGradientTransform(slidePercent: _shimmerController.value), ); - bool get isSized => (context.findRenderObject() as RenderBox).hasSize; + bool get isSized => + (context.findRenderObject() as RenderBox?)?.hasSize ?? false; Size get size => (context.findRenderObject() as RenderBox).size;