Hasini
Hasini

Reputation: 337

How to avoid flutter page scroll up when the keyboard comes up

I want to get input from these TextField. When I focus the TextField the keyboard comes up and page scroll up. I do not need that scrolling. How can I avoid this?

Normal View

After TextField Focusing

Upvotes: 1

Views: 8010

Answers (3)

Bhavika Pal
Bhavika Pal

Reputation: 31

textFiled when the keyboard opens then scroll your TextFiled to use SingleChildScrollView in your main Column Widget Wrap it.

SingleChildScrollView( keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, reverse: true, child: Column( children: []), );

Upvotes: 1

CopsOnRoad
CopsOnRoad

Reputation: 268464

Use

Scaffold(
  resizeToAvoidBottomInset: false,
  ...
)

From docs:

For example, if there is an onscreen keyboard displayed above the scaffold, the body can be resized to avoid overlapping the keyboard, which prevents widgets inside the body from being obscured by the keyboard.

Upvotes: 8

Amit Prajapati
Amit Prajapati

Reputation: 14335

To get better idea follow this reference link : https://api.flutter.dev/flutter/material/Scaffold/resizeToAvoidBottomInset.html

 return Scaffold(
      resizeToAvoidBottomInset : false,
      body: Container(),
    )

Upvotes: 5

Related Questions