From 9e46c67e9a675f7f4ee018459b3d84fa58894c98 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Wed, 6 Mar 2024 12:51:52 -0800 Subject: [PATCH] Fix code sample failing in smoke test (#144709) This fixes the silent failure reported in https://github.com/flutter/flutter/issues/144353. I am experimenting in https://github.com/flutter/flutter/pull/144706 with whether the failure should have been non-silent. --- .../api/lib/material/color_scheme/dynamic_content_color.0.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart b/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart index e3b2b96458..2dde166aba 100644 --- a/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart +++ b/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart @@ -188,6 +188,9 @@ class _DynamicColorExampleState extends State { Future _updateImage(ImageProvider provider) async { final ColorScheme newColorScheme = await ColorScheme.fromImageProvider( provider: provider, brightness: isLight ? Brightness.light : Brightness.dark); + if (!mounted) { + return; + } setState(() { selectedImage = widget.images.indexOf(provider); currentColorScheme = newColorScheme;