How to make widget stick to top of keyboard

Related searches

I'd like to make a widget that sticks to the bottom of the page, and then is pinned to the top of the keyboard (when it appears).

Note how the input textfield is pinned to the keyboard in the image below:

How would I do this? I tried putting it in the bottomNavigationBar, but this (obviously) didn't work. Is there a builtin way to do this?

This is a working example of the thing you want. I think! Just copy/paste/run

What's important in this example is the Expanded. A really nice widget that expands to as much space as it can get. And in result pushing the chat box down as much as possible (Bottom of the screen or bottom of the keyboard)

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
        return new MaterialApp(
            title: 'Flutter Demo',
            theme: new ThemeData(
                primarySwatch: Colors.blue,
            ),
            home: new MyHomePage(title: 'Flutter Demo Home Page'),
        );
    }
}

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

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

class _MyHomePageState extends State<MyHomePage> {

    @override
    Widget build(BuildContext context) {
        return new Scaffold(
            appBar: new AppBar(
                title: new Text('49715760 Stackoverflow'),
            ),
            body: new Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                    new Expanded(
                        child: new Material(
                            color: Colors.red,
                            child: new Text("Filled"),
                        ),
                    ),
                    new Container(
                        color: Colors.white,
                        padding: new EdgeInsets.all(10.0),
                        child: new TextField(
                            decoration: new InputDecoration(
                                hintText: 'Chat message',
                            ),
                        ),
                    ),
                ],
            ),
        );
    }
}

How to make bottom "appbar" that sticks to the top of the keyboard , Id like the message text field to be at the bottom of the screen, but then stick to you could create a Stack, and then wrap the thing inside an Align widget with� Any element can stick: although common use is for navigation menus, or header the plugin will let you pick any unique element with a name, class or ID to stick at the top of the page once you scroll past it. Use it for sticky widget, sticky sidebar, sticky header, sticky menu, sticky header, sticky call-to-action box, sticky banner ad, etc.

The best way to resolve this is to use a dedicated widget.
MediaQuery.of(context).viewInsets.bottom will give you the value of the height covered by the system UI(in this case the keyboard).
import 'dart:async';

import 'package:flutter/material.dart';

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

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

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(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: _getBody(),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }

  Widget _getBody() {
    return Stack(children: <Widget>[
      Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage("assets/sample.jpg"), fit: BoxFit.fitWidth)),
        // color: Color.fromARGB(50, 200, 50, 20),
        child: Column(
          children: <Widget>[TextField()],
        ),
      ),
      Positioned(
        bottom: MediaQuery.of(context).viewInsets.bottom,
        left: 0,
        right: 0,
        child: Container(
          height: 50,
          child: Text("Hiiiii"),
          decoration: BoxDecoration(color: Colors.pink),
        ),
      ),
    ]);
  }
}

How to make widget stick to top of keyboard, I'd like to make a widget that sticks to the bottom of the page, and then is pinned to the top of the keyboard (when it appears).Note how the input textfield is� I've got a "save" button which I want to push up together with the soft keyboard. So when the user clicks an EditText in my layout, then the button has to stay above the keyboard. Now the button becomes hidden underneath the keyboard.

there is a lib for that:

https://pub.dev/packages/keyboard_attachable

Widget build(BuildContext context) => FooterLayout(
          footer: MyFooterWidget(),
          child: PageMainContent(),
        );

Can't stick TextField to keyboard when opening keyboard on iOS , I'm trying to stick TextField to the top of keyboard like in messaging apps Widget build(BuildContext context) { return CupertinoPageScaffold(� I'm creating an application which has a "floating" widget which can be dragged around inside the application window. But it starts up, or tends to go behind other widgets sometimes. Is there any way to make sure that the widget in my application stays on top of all other widgets whenever it is made visible? Thanks.

This worked for me,

showBottomSheet(
  context: context,
  builder: (context) => Container(
  height: // YOUR WIDGET HEIGHT
  child: // YOUR CHILD
)

showBottomSheet is a flutter inbuilt function.

Avoiding the On-Screen Keyboard in Flutter, We can get the height of the on-screen keyboard by doing a MediaQuery and Then we can wrap our widget in a simple Padding widget that� To see if any of the volume keys where stuck on my keyboard I pressed each key a couple of times nothing happened to the volume bar and they weren't stuck, then I went to the volume icon on the task bar and turned the volume up to the maximum and it made the notification sound but then by itself turned the down to mute from 100 to 99, 98 etc..

How to fix bottom overflowed when keyboard shows error in Flutter , How to fix bottom overflowed when keyboard shows error in Flutter - Programming Addict Top Duration: 1:19 Posted: Jan 13, 2019 Step 1, Disconnect the keyboard from its power source. If you're using a laptop, this entails turning off and unplugging the laptop and removing its battery if possible. If you're using a standalone keyboard, unplugging it and/or removing the batteries will suffice.Step 2, Spray the keyboard with compressed air. Use the compressed air to blow any debris or dust out from the spaces between the keys and the keyboard base. Spritzing the compressed air around each key is a good idea; even if not

Click the Apple menu and select "System Preferences." Click the "Keyboard" option and then check "Show viewers for keyboard, emoji, and symbols in menu bar." Click the viewer icon that appears in the menu bar and select "Show Emoji & Symbols." Browse through the categories of symbols and double-click the one you want to insert.

Whether you want to use a keyboard shortcut or a graphical menu these are the ideal ways to make a window always-on-top. And, these tools work with pretty much any version of Windows. Another quick thing to note: there are some great apps out there that can make a window stay always on top in addition to doing other things.

Comments
  • I don't have the code on hand. But i think you can do this by making a Scaffold. In the body of the scaffold you place a expanded. The childs of the expanded are your chat messages etc. And under the expanded you place the text box like in whats app. The expanded will constantly expand to the end of your screen leaving enough room for a textbox if you place it under the expanded. If you can't figure it it i'll try it. Let me know!
  • android example?
  • This solution sadly is similar to the other in that it is not ideal as the TextField moves to its new position at a different speed to the keyboard, causing a less than ideal animation.
  • Thank you ! Using Positioned + MediaQuery nailed it :)
  • This is a nice clean solution, however not ideal as the TextField moves to its new position at a different speed to the keyboard, causing a less than ideal animation.