-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Keyboard unexpectedly closes if its in a bottomSheet of a named Route #36271
Comments
Update 1: Providing a Global Key to the Container in the bottom Sheet forces the keyboard to stay alive, but then a red screen flickers on Ios and i get the following error: I/flutter (15864): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (15864): The following assertion was thrown while finalizing the widget tree:
I/flutter (15864): Duplicate GlobalKey detected in widget tree.
I/flutter (15864): The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of
I/flutter (15864): the widget tree being truncated unexpectedly, because the second time a key is seen, the previous
I/flutter (15864): instance is moved to the new location. The key was:
I/flutter (15864): - [GlobalKey#06a16]
I/flutter (15864): This was determined by noticing that after the widget with the above global key was moved out of its
I/flutter (15864): previous parent, that previous parent never updated during this frame, meaning that it either did
I/flutter (15864): not update at all or updated before the widget was moved, in either case implying that it still
I/flutter (15864): thinks that it should have a child with that global key.
I/flutter (15864): The specific parent that did not update after having one or more children forcibly removed due to
I/flutter (15864): GlobalKey reparenting is:
I/flutter (15864): - _InheritedResetNotifier
I/flutter (15864): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter (15864):
I/flutter (15864): When the exception was thrown, this was the stack:
I/flutter (15864): #0 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2485:15)
I/flutter (15864): #1 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2510:8)
I/flutter (15864): #2 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:702:18)
I/flutter (15864): #3 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
I/flutter (15864): #4 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
I/flutter (15864): #5 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
I/flutter (15864): #6 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
I/flutter (15864): #10 _invoke (dart:ui/hooks.dart:236:10)
I/flutter (15864): #11 _drawFrame (dart:ui/hooks.dart:194:3)
I/flutter (15864): (elided 3 frames from package dart:async)
I/flutter (15864): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/HwSecImmHelper(15864): mSecurityInputMethodService is null
I/flutter (15864): Another exception was thrown: Duplicate GlobalKey detected in widget tree. updated CodeSnippet:class SecondPage extends StatefulWidget {
SecondPage({Key key}) : super(key: key);
@override
_SecondPageState createState() => _SecondPageState();
}
class _SecondPageState extends State<SecondPage> {
static final Key _key = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('it does not work here'),
),
bottomSheet: Container(
key: _key,
width: double.infinity,
color: Colors.lightGreen,
height: 90,
child: Center(child: Container(width: 200, child: TextField())),
),
);
}
} |
Found a solution: |
Thank you Menelphor, you solved it! |
Hi @Menelphor |
You also can wrapped it with stack then using Positioned with bottom: 0.. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Issue
If I'm tapping on a TextField inside a Bottom Sheet of a Scaffold of a Page which is not the home page, the keyboard disappears.
This behavior also occures on the home screen if i set:
Steps to Reproduce
Sample Code
Logs
Flutter analyze
Flutter doctor
The text was updated successfully, but these errors were encountered: