-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Here is my simple flutter application with showModalBottomSheet, it contains a textfield and a button. When the text field is pressed keyboard pops up. But, modalbottomsheet does not move up along with the keyboard. Tried adding bottom viewInsets padding. Is there any other way to move modalbottomsheet along with the keyboard?
import 'package:flutter/material.dart';
`void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
resizeToAvoidBottomInset: false,
body: HomeScreen(),
),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.yellow[200],
child: Center(
child: RaisedButton(
color: Colors.purple[100],
child: Text('Button'),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return MyBottomSheet();
});
},
),
),
);
}
}
class MyBottomSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Colors.pink[200],
child: Column(
children: [
TextField(
autofocus: true,
),
RaisedButton(
child: Text('Next'),
onPressed: () {},
),
],
),
),
);
}
}
LucasG04, rachid-switchy, vanlooverenkoen, kunit1, maxcorrads and 15 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ZainUrRehmanKhan commentedon Dec 1, 2020
Current Work Around:
showBottomSheet has a property
isScrollControlled
, make it true.Remove
Scaffold
fromMyBottomSheet
and give your container a fixedheight
. Wrap yourMyBottomSheet
Container
withPadding
and useMediaQuery.of(context).viewInsets
for padding.ZainUrRehmanKhan commentedon Dec 1, 2020
@TahaTesser Please Review this issue, The BottomSheet should be automatically moved above on the Keyboard popup, if possible.
pedromassangocode commentedon Dec 1, 2020
Hi @preethishenoy
Can you please elaborate what do you exactly want? It is not clear for me.
Thank you
preethishenoy commentedon Dec 1, 2020
Thanks for your response.
I did try this and it works.I have a navigation controller also placed over the modal screen. I have placed a navigation to transition from screen 1 to screen 2.I am using this modal sheet to implement a basic login workflow. Here , screen 1 is my Phone number screen and screen 2 is the OTP screen. Once I have a navigation controller, This issue does come up. Here is the link to my sample code. Appreciate any workaround for this issue.
https://drive.google.com/file/d/1vcEM8ltzeCClVOcm9gjbevVYpt3czVKC/view?usp=sharing
preethishenoy commentedon Dec 1, 2020
Sorry, I have elaborated my issue and also added a link to my sample code above.
pedromassangocode commentedon Dec 2, 2020
From what you have said and by running the code it is not clear to me what is the issue here.
ZainUrRehmanKhan commentedon Dec 2, 2020
@pedromassangocode try the above code, the bottom sheet will be hidden behind the keyboard, we want the bottom sheet to move along the keyboard by default, so we can view it above the keyboard without adding
isScrollable = true
inshowModalBottomSheet
and wrappingContainer
inMyBottomSheet
with padding like this.pedromassangocode commentedon Dec 2, 2020
Thanks, now it is clear what the issue is.
flutter doctor -v
52 remaining items
g-apparence commentedon Aug 18, 2023
Another possibility for those who are stuck with this
1 - install the
flutter_keyboard_visibility
package2 - listen for keyboard changes inside your modal content state
(Don't forget to dispose it).
If you don't wait 500Ms it seems that the keyboard is not fully opened and the bottomInset will return 0.
Give your content a height (here it is 372).
Now you can just use that bottomPadding in your modal content. This will correctly up your content according to the keyboard.
(Tested on Android and iOS).
PollyGlot commentedon Sep 18, 2023
I am afraid but the solution proposed above doesn't work for me, all my bottomSheets rest fixed. It was working good before 3.10, since then till now with 3.13.4 everything is blocked and I can't find any solutions for now
Washoo commentedon Oct 1, 2023
You need to specify the context for the builder, for example:
The MediaQuery takes the bottom padding of the builder, and it will push the modal when the keyboard opens. I am using the latest Flutter version (3.13.6), and it works.
mafreud commentedon Nov 2, 2023
@Washoo Thanks. It works with 3.13.9.
@pedromassangocode I think the issue has been solved and it is time to close.
mafreud commentedon Nov 2, 2023
@pedromassango
juequinterore commentedon Dec 1, 2023
Adding some info that could be useful.
In my case the issue started happening when we upgraded Flutter from 3.3.10 to 3.19.3.
The issue ended up being that, for preventing scaling the app text according to the phone settings, we were using this code:
After changing that code into this new code:
It was solved.
yunweneric commentedon Dec 15, 2023
Finally I got the solution to this issue!
Wrap the child of the bottom sheet with padding and add bottom padding
Screen Utils
If you are using the flutter_screenutil package then add this line
A7medking1 commentedon Jan 2, 2024
Thanks worked
andresteves commentedon Feb 26, 2025
iOS works fine but on Android it still hides behind keyboard.
If isScrollControlled: Platform.isAndroid ? true : false then it fills whole screen.
Flutter version
Flutter (Channel stable, 3.27.1, on macOS 14.4.1 23E224 darwin-arm64, locale en-DE)
flutter-triage-bot commentedon Feb 26, 2025
This issue is missing a priority label. Please set a priority label when adding the
triaged-design
label.yubarajshrestha commentedon Apr 6, 2025
The solution is pretty straight forward. Update your widgets in following manner.
Your
YourWidgetOrLayout()
should use theColumn
orListView
.or