IsaiasSantana / keyboard_utils

A Flutter plugin to check keyboard visibility.
MIT License
49 stars 49 forks source link

Keyboard height problem #45

Open NerdFaisal404 opened 2 years ago

NerdFaisal404 commented 2 years ago

I am not getting keyboard height properly.

LostInDarkMath commented 2 years ago

I have the same issue. This given height of the keyboard is obviously incorrect.

LostInDarkMath commented 2 years ago

On Android, I get actually 218, but I expect 249, which is the value of

EdgeInsets.fromWindowPadding(WidgetsBinding.instance!.window.viewInsets,WidgetsBinding.instance!.window.devicePixelRatio).bottom
MagTuxGit commented 2 years ago

I'm getting wrong keyboard height on: Xiaomi MI 9T Pro Redmi Note 6 Pro Five other Android models I was able to test are fine.

LostInDarkMath commented 2 years ago

Okay, I found a solution. My solution above will only work on Android 10 and below, so do not use it.

To make the keyboard height of this package work I use this:

willShowKeyboard: (double keyboardHeight) {
  if(Platform.isAndroid){
    keyboardHeight +=  WidgetsBinding.instance!.window.viewPadding.top / WidgetsBinding.instance!.window.devicePixelRatio;
  }

  print('keyboard height: $keyboardHeight');
}

Hope that helps anybody.

root458 commented 2 years ago

My keyboard works well only on debug mode. I don't get what happens on release versions of the app

Devices tested on: Oppo A3S, Android 8.1 ARM64 Samsung A10S, Android 11