-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate global key in the first screen #112
Comments
This is a difficult problem to solve due to how the slide motion during the pagination is implemented. This happens when your main content has a widget with GlobalKey. During the pagination the main content widgets are duplicated in the Offstage widget to be able to calculate the size. This is not something we can quickly fix, but I will keep an eye on this. What is your use case? If you need a form key or something similar that will be used to refer the entire widget tree, injecting the key with the |
This is a problem for me. I used the key inside a Form widget, when clicking on a button the validate() function invoke on this key. In addition, I can't use Form.of instead of the key because the Form in the content of the modal and the button is located as StickyActionBar (The form does not contain the button.) Do you have any idea for me? |
I ran into the same issue when re-using some (proprietary) form component widgets that had |
Thanks @tp We are aware of this. Currently, this issue is on me and I am trying to find time to address this issue. On top of my priority list. If you want to debug and create PR, I can give you background information on the root cause. |
I came up with this workaround for the app I am working on, where gladly we control all child widgets of the modal: @override
Widget build(BuildContext context) {
final isOffstage =
context.findAncestorWidgetOfExactType<Offstage>()?.offstage == true;
return Widget(
// Do not set the key when rendering offstage (e.g. WoltModalSheet) to avoid duplicate `GlobalKey`s
// (This will not impact any behavior as these are only needed for scrolling on-screen widgets anyway)
key: isOffstage ? null : fieldItem.widgetKey, |
Very smart workaround! I will give a shot to a more proper solution. It is nice to know that a workaround is possible. |
I have the same issue, will remove the Form from the widget for now. |
Any new solutions? final isOffstage = context.findAncestorWidgetOfExactType<Offstage>()?.offstage == true; On first page i got wrong UPD. class _SignInWoltpageState extends State<SignInWoltpage> {
bool isOffstageFromDelayedCheck = true;
@override
void initState() {
super.initState();
checkVisibilityInitially();
}
void checkVisibilityInitially() {
Future.delayed(const Duration(milliseconds: 50), () {
if (!mounted) return;
setState(() {
isOffstageFromDelayedCheck = context.findAncestorWidgetOfExactType<Offstage>()?.offstage ?? false;
});
});
}
@override
Widget build(BuildContext context) {
final isOffstageFromBuildCheck = context.findAncestorWidgetOfExactType<Offstage>()?.offstage ?? true;
final isOffstage = isOffstageFromDelayedCheck && isOffstageFromBuildCheck; |
Is there meanwhile another Solution? |
Bug report
Duplicate global key on the content on the first page from two pages when moving to the second page.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
The first page does not need to be rebuilt when moving to the second page
The text was updated successfully, but these errors were encountered: