You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I use a PortalFollower in combination with an OpenContainer (aka 'container transform', which provides a nice transition animation when pushing a route), when the container opens, I get:
The following PortalNotFoundError was thrown building _PortalTargetVisibilityBuilder(visible: false, closeDuration: null, builder: Closure: (BuildContext, bool) => Widget, dirty, state: _PortalTargetVisibilityBuilderState#7635b):
Error: Could not find a Portal above this PortalTarget(debugName: null, portalCandidateLabels=[[String <'test'>]]).
The relevant error-causing widget was:
PortalTarget PortalTarget:file:///Users/james/GithubRepos/portal_bug/lib/main.dart:48:18
When the exception was thrown, this was the stack:
0 _PortalTargetState.build. (package:flutter_portal/src/portal_target.dart:265:11)
1 _PortalTargetVisibilityBuilderState.build (package:flutter_portal/src/portal_target.dart:449:26)
I think that during the transition animation, PortalTarget cannot find a PortalLinkScope
// From portal_target.dart line 263:final scope =PortalLinkScope.of(context, widget.portalCandidateLabels);
if (scope ==null) {
throwPortalNotFoundError._(widget);
}
I think because the animation detatches the whole widget from the original context to do the animation to the new route. This error occurs even if I set visibility to false on PortalTarget before triggering the animation.
I guess this is more a problem with the animations package but it would be nice if it could not throw an error if PortalLinkScope is not found but visibility is false, for example:
final scope =PortalLinkScope.of(context, widget.portalCandidateLabels);
if (scope ==null) {
// Add this check:if(widget.visible) {
throwPortalNotFoundError._(widget);
}
else {
returnContainer();
}
}
Here's a minimal reproducible example, just tap the button to trigger the error:
However, for your scenario, what about something like: visible ? PortalTarget(..., child: YourButton()) : YourButton(). In other words, when not visible, just directly remove the PortalTarget from the tree.
Thanks, that seems to work. I'm still not entirely sure why it's happening as I'm not using a closeDuration on PortalTarget (so I don't think it animates?) and OpenContainer is quite complex. But I think this workaround may be the best solution
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm using flutter_portal 1.1.4 with the animations package from flutter.dev.
If I use a
PortalFollower
in combination with anOpenContainer
(aka 'container transform', which provides a nice transition animation when pushing a route), when the container opens, I get:I think that during the transition animation,
PortalTarget
cannot find aPortalLinkScope
I think because the animation detatches the whole widget from the original context to do the animation to the new route. This error occurs even if I set visibility to false on
PortalTarget
before triggering the animation.I guess this is more a problem with the
animations
package but it would be nice if it could not throw an error ifPortalLinkScope
is not found but visibility is false, for example:Here's a minimal reproducible example, just tap the button to trigger the error:
The text was updated successfully, but these errors were encountered: