The following assertion was thrown while finalizing the widget tree:
Duplicate GlobalKey detected in widget tree.
The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of the widget tree being truncated unexpectedly, because the second time a key is seen, the previous instance is moved to the new location. The key was:
[LabeledGlobalKey#1704b]
This was determined by noticing that after the widget with the above global key was moved out of its previous parent, that previous parent never updated during this frame, meaning that it either did not update at all or updated before the widget was moved, in either case implying that it still thinks that it should have a child with that global key.
The specific parent that did not update after having one or more children forcibly removed due to GlobalKey reparenting is:
DefaultSelectionStyle
A GlobalKey can only be specified on one widget at a time in the widget tree.
When the exception was thrown, this was the stack:
The following assertion was thrown while finalizing the widget tree: Duplicate GlobalKey detected in widget tree.
The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of the widget tree being truncated unexpectedly, because the second time a key is seen, the previous instance is moved to the new location. The key was:
0 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:3225:15)
1 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:3250:8)
2 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:987:19)
3 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
4 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
5 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
6 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
7 _invoke (dart:ui/hooks.dart:312:13)
8 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
9 _drawFrame (dart:ui/hooks.dart:283:31)
ElevatedButton( child: const Text("Multiple image editor"), onPressed: () async { var editedImage = await Navigator.push( context, MaterialPageRoute(builder: (context) { return ImageEditor( images: [ imageData, imageData, ], ); }), ); if (editedImage != null) { image = editedImage; setState(() {}); } }, ),