Flutter Keyboard Makes Textfield Hide

Flutter Keyboard makes textfield hide

This was the case with me . You are definitely wrapping a scaffold inside another scaffold . there should be only one scaffold widget inside your flutter app i.e the main layout . Simple remove all the ancestor scaffolds you have and keep only one scaffold . dont wrap a scaffold into another scaffold .inspite of that you can wrap a scaffold inside a container .

Make sure in your main.dart file you are not doing this :-

✖✖

return Scaffold(
body : YourNewFileName(),
);

Inspite of the above code do this:-
✔✔

return YourNewFileName();

Keyboard hides textfield on Flutter

use MediaQuery.of(context).viewInsets.bottom and add it to your bottom navigation height

        child: Form(
child: Container(
height: 180.0 + MediaQuery.of(context).viewInsets.bottom,
color: Colors.blue[400],
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(children: [
Container(
height: 50,
decoration: BoxDecoration(
color: Colors.white,
),
),```

Keyboard hides TextField - Flutter

Wrap either one of you Columns (probably the outer one) with a SingleChildScrollView. The issue is that simply popping up the keyboard doesn't suddenly tell the layout that it needs to be able to scroll. You have explicitly say you want it to be able to scroll.

See this for more information on the SingleChildScrollView.

Flutter - Keyboard Hides TextField

If you have added singleChildScrollView it will automatically move upwards when the keyboard is open. It wouldn't need the padding again.

Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(),
body: Padding(
padding: EdgeInsets.all(20),
child: SingleChildScrollView(
child: Column(children: [
SizedBox(
height: 500,
),
Container(child: TextField())
]),
)));

TextField hides behind Keyboard in Flutter 3.0.0

I found the solution. I had installed the flutter_screenutil package and inserted it above my widget tree - above MaterialApp and I'd also set useInheritedMediaQuery: true. This prevented widget rebuilds for things like keyboard state change.

Moving the ScreenUtils widget below MaterialApp fixed it.

Flutter prevent keyboard from hiding TextField on tap in Dialog

It looks like I finally find the solution myself. As I mention in my question I had already tried adding a Scaffold to the Dialog without success, however I was placing the Scaffold inside the Dialog. I've now tried placing the Dialog inside the Scaffold and the problem is solved. One side-effect is that the Dialog is no longer dismissible but this can be fixed by wrapping the Scaffold in a GestureDetector and manually dismissing. The full working code is now:

import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Builder(
builder: (context) => TextButton(
child: const Text("Open dialog"),
onPressed: () {
showDialog(
context: context,
builder: (context) => _dialog(context),
barrierDismissible: true,
);
},
),
),
),
),
);
}

Widget _dialog(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Scaffold(
backgroundColor: Colors.transparent,
body: Dialog(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(height: 200, color: Colors.red),
const TextField(decoration: InputDecoration(hintText: 'TF 1')),
const TextField(decoration: InputDecoration(hintText: 'TF 2')),
const TextField(decoration: InputDecoration(hintText: 'TF 3')),
const TextField(decoration: InputDecoration(hintText: 'TF 4')),
const TextField(decoration: InputDecoration(hintText: 'TF 5')),
const TextField(decoration: InputDecoration(hintText: 'TF 6')),
const TextField(decoration: InputDecoration(hintText: 'TF 7')),
Container(height: 200, color: Colors.blue),
],
),
),
),
),
);
}
}

Flutter TextFormField hidden by keyboard

thanks solve my problem with this padding on bottom of textfield

    Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom));

and mare reverse list



Related Topics



Leave a reply



Submit