Skip to content

TextField is hidden by keyboard inside of a Modal Bottom Sheet #18564

Closed
@IhorKlimov

Description

@IhorKlimov
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: ''),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('')),
      body: Container(),
      floatingActionButton: FloatingActionButton(onPressed: () {
        showModalBottomSheet(
            context: context,
            builder: (context) {
              return SizedBox(
                height: 300.0,
                child: Scaffold(
                  body: ListView.builder(
                    itemBuilder: (context, index) {
                      return TextField(
                        decoration:
                            InputDecoration(labelText: index.toString()),
                      );
                    },
                    itemCount: 30,
                  ),
                ),
              );
            });
      }),
    );
  }
}

Result

screenshot_1529336524

Clicked on 4th item

screenshot_1529336530

Perfectly, Modal Bottom Sheet should be lifted up till a TextField is visible, just like FAB

Flutter Doctor

[√] Flutter (Channel master, v0.5.5-pre.46, on Microsoft Windows [Version 10.0.17134.112], locale en-US)
\Error retrieving device properties for ro.product.cpu.abi:
error: closed
                                                                                                                                                                                                       [
!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    X Android license status unknown.
[√] Android Studio (version 3.1)
[√] VS Code, 64-bit edition (version 1.24.0)
[√] Connected devices (1 available)

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions