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.
This commit is contained in:
Michael Goderbauer
2024-03-06 12:51:52 -08:00
committed by GitHub
parent f38c5ad441
commit 9e46c67e9a

View File

@@ -188,6 +188,9 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
Future<void> _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;