Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to push all content up when open keyboard

Is it possible to push all content up when open keyboard? (not only textField area, whole page push up)

   showModalBottomSheet(
       context: context,
       builder: (BuildContext context) {
            return BottomSheet();
       },
   isScrollControlled: true);

BottomSheet class

class BottomSheet extends StatefulWidget {
  @override
  _BottomSheetState createState() => _BottomSheetState();
}

class _BottomSheetState extends State<BottomSheet> {

  @override
  Widget build(BuildContext context) {
    return
      SingleChildScrollView(
        padding: EdgeInsets.only(
            bottom: MediaQuery.of(context).viewInsets.bottom),
            child: Container(
                child: Column(
                  children: <Widget>[...

I want to like this push-up,

need to like this push-up, here

But Current output is,

current output here

like image 840
BIS Tech Avatar asked Sep 07 '25 15:09

BIS Tech


2 Answers

Simply putting reverse=true inside the SingleChildScrollView will suffice.

Widget build(BuildContext context) {
  return Scaffold(
    body: SafeArea(
      child: SingleChildScrollView(
        reverse: true,
        child: Container(
          ........
          ........ 

enter image description here

like image 72
Astik Anand Avatar answered Sep 09 '25 17:09

Astik Anand


You can simply give the widget a bottom position of MediaQuery.of(context).viewInsets.bottom if you are using a stack.

In your case, set margin : to MediaQuery.of(context).viewInsets.bottom instead of padding.

like image 31
Kelvin Mboto Avatar answered Sep 09 '25 17:09

Kelvin Mboto