Describe the bug
Have strange errors with NavigationBar. When I click button I got the error "Duplicate GlobalKey detected in widget tree". Found only 1 workaround: to use NoAnimationTransitionDelegate. My code:
======== Exception caught by widgets library =======================================================
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<BeamerState>#0a75e beamer_global_key]
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:
- KeyedSubtree-[GlobalKey#2a673]
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:
#0 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:3083:15)
#1 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:3108:8)
#2 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:19)
#3 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#4 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#5 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
#6 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#7 _invoke (dart:ui/hooks.dart:145:13)
#8 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#9 _drawFrame (dart:ui/hooks.dart:112:31)
====================================================================================================
Ok, I solved this. The problem was on line
context.beamToReplacementNamed(url);
Replaced it with
_beamerDelegate.beamToReplacementNamed(url);
Now it works like a charm
Describe the bug Have strange errors with NavigationBar. When I click button I got the error "Duplicate GlobalKey detected in widget tree". Found only 1 workaround: to use NoAnimationTransitionDelegate. My code:
In main file have 2 top-level delegates:
And HomeScreen:
Beamer version: 1.5.3
Smartphone:
Additional context Full error: