mcrovero / flutter_interactive_keyboard

More on https://medium.com/@mattia_crovero/interactive-keyboard-in-flutter-5d7ac6ee096b
BSD 2-Clause "Simplified" License
53 stars 26 forks source link

[FEATURE REQUEST] Allow resizeToAvoidBottomInset to be true #12

Closed Haidar-Hammoud closed 2 years ago

Haidar-Hammoud commented 4 years ago

Love this library, this was definitely something that should have been included with flutter out of the box.

I've noticed it only works when resizeToAvoidBottomInset is false. It would be great if you could allow for the value to be true that way things stick above the keyboard as it changes its height (e.g. a chat textfield box at the bottom)

david-shortman commented 4 years ago

Sounds like a good idea!

This repo is open for pull requests, but not being actively developed/progressed. I'll leave this issue open for someone to see if they'd like to make a contribution to resolve it.

Fox520 commented 3 years ago

I found this to suit my use case. In keyboard_manager.dart replace

var bottom = MediaQuery.of(context).viewInsets.bottom;

with

final viewInsets = EdgeInsets.fromWindowPadding(
        WidgetsBinding.instance!.window.viewInsets,
        WidgetsBinding.instance!.window.devicePixelRatio);
var bottom = viewInsets.bottom;

Add this to the onKeyboardClose callback

WidgetsBinding.instance?.addPostFrameCallback((_) {
    if (mounted) setState(() {});
 });

Credit: https://github.com/maxsalo17/flutter_interactive_keyboard/commit/7f3bedde93a1ed8562613536f7f63836a2128da9