GithubHelp home page GithubHelp logo

flutter_keyboard_visibility's People

Contributors

adee42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_keyboard_visibility's Issues

MissingPluginException

Hey man,

Thank you for making this package, I am really excited to use it.
Unfortunately, the package throws a MissingPluginException:

`The following MissingPluginException was thrown while activating platform stream on channel github.com/adee42/flutter_keyboard_visibility:

MissingPluginException(No implementation found for method listen on channel github.com/adee42/flutter_keyboard_visibility)`

I cloned your repo, added it to my project and updated my dependencies. Any idea on why this is happening?

Broken after Interstitial Ad by admob

Testing this case scenario using version 0.5.6 not errors are thrown, works fine before Interstitial ad is executed

Version 0.5.5 crashes the app, also works fine before Interstitial ad is executed

E/AndroidRuntime( 6558): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getWindowVisibleDisplayFrame(android.graphics.Rect)' on a null object reference
E/AndroidRuntime( 6558): 	at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.onGlobalLayout(KeyboardVisibilityPlugin.java:40)
E/AndroidRuntime( 6558): 	at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
E/AndroidRuntime( 6558): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2372)
E/AndroidRuntime( 6558): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1481)
E/AndroidRuntime( 6558): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7393)
E/AndroidRuntime( 6558): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
E/AndroidRuntime( 6558): 	at android.view.Choreographer.doCallbacks(Choreographer.java:761)
E/AndroidRuntime( 6558): 	at android.view.Choreographer.doFrame(Choreographer.java:696)
E/AndroidRuntime( 6558): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
E/AndroidRuntime( 6558): 	at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime( 6558): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 6558): 	at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 6558): 	at android.app.ActivityThread.main(ActivityThread.java:6724)
E/AndroidRuntime( 6558): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6558): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
E/AndroidRuntime( 6558): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process ( 6558): Sending signal. PID: 6558 SIG: 9

I can't get apk after i added "keyboard_visibility: ^0.5.6" into pubspec.yaml

PS C:\Users\daydreamer\KaynakKodlari> flutter build apk --release --build-name=1.1.3 --build-number=2
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\src\flutter\flutter_windows_v1.5.4-hotfix.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.6\android\src\main\java\io\flutter\plugins\sharedpreferences\SharedPreferencesPlugin.java:25: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding has been deprecated
setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
^
1 warning
Removed unused resources: Binary resource data reduced from 70KB to 60KB: Removed 13%

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':keyboard_visibility:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\daydreamer.gradle\caches\transforms-2\files-2.1\a1e87f5443b1512d74d302dbaa8fc6ba\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 C:\Users\daydreamer\.gradle\caches\transforms-2\files-2.1\a1e87f5443b1512d74d302dbaa8fc6ba\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BU�LD FAILED in 46s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 46,6s
Removed unused resources: Binary resource data reduced from 70KB to 60KB: Removed 13%

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':keyboard_visibility:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\daydreamer.gradle\caches\transforms-2\files-2.1\a1e87f5443b1512d74d302dbaa8fc6ba\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 C:\Users\daydreamer\.gradle\caches\transforms-2\files-2.1\a1e87f5443b1512d74d302dbaa8fc6ba\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BU�LD FAILED in 46s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 46,6s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin connectivity...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 5,0s
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'connectivity'.

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUİLD FAILED in 4s

The plugin connectivity could not be built due to the issue above.

Normally when i connect my phone to the pc there is no problem with this library but when i try to get apk like "flutter build apk --release" it shows the error.

And it does not work in ios real device.

Listener is not working when listener is disposed in dispose()

This code is not working. As soon as I remove the disposing of the listener, it works fine.

Btw: is there a way to get the event immediately? Not it's delayed when the keyboard is popping up.

final keyboardListener = KeyboardVisibilityNotification();

@override
void initState() {
  super.initState();
  keyboardListener.addNewListener(
      onChange: (bool visible) {
        print('KEYBOARD: $visible');
      },
    );
}

@override
void dispose() {
  keyboardListener.dispose();
  super.dispose();
}

Cant trigger listener in my own code

Hi,
Thanks for the plugin.

I can see that your example works. When I try to copy / paste the example code into my own code and include your library it doesn't seem to ever call the listener.
In the listener, I just put a print statement to show the $visible value but it never seems to be called.
Is there anything else I need to do to enable it ?

Fail to get mainView

@Override
    public void onActivityStarted(Activity activity) {
        try {
            mainView = ((ViewGroup)activity.findViewById(android.R.id.content)).getChildAt(0);
            mainView.getViewTreeObserver().addOnGlobalLayoutListener(this);
        }
        catch (Exception e) {
            // do nothing 
        }
    }

Change DidShow to WillShow

Hi, in your plugin you use DidShow, and WillHide

[center addObserver:self selector:@selector(didShow) name:UIKeyboardDidShowNotification object:nil];
[center addObserver:self selector:@selector(didHide) name:UIKeyboardWillHideNotification object:nil];

Could be possible to change UIKeyboardDidShowNotification with UIKeyboardWillShowNotification in order to make consistent with WillHide? Or maybe add it? Thanks!

Why this was broken????

0.5.3 ----> listening is broken
0.5.4,0.5.5 -----> java null pointer exception...

plz fix it

Only 0.5.2 works fine, what did you do??

Probably conflicts with another package

Thanks for making this! I am also using another package image_cropper: ^1.2.0
In my form page, I am using keyboard_visibility: ^0.5.7. It works fine. But when I open the image crop screen using the aforementioned package and come back to my form screen, keyboard_visibility package seems to stop working!
For now I am using a fork of this package flutter_keyboard_visibility: ^0.7.0 which seems to be working fine this scenario too.

Release not working. :keyboard_visibility:verifyReleaseResources'

Hi,
I have an issue after I run those command:

flutter run --release --verbose
flutter run --release

it's show me :

[        ] FAILURE: Build failed with an exception.
[        ] * What went wrong:
[        ] Execution failed for task ':keyboard_visibility:verifyReleaseResources'.
[        ] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[        ]    > Android resource linking failed
[        ]      /Users/abdulrahman/.gradle/caches/transforms-2/files-2.1/a219aaa53005fa677df3bfd14ede3871/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
[        ]      /Users/abdulrahman/.gradle/caches/transforms-2/files-2.1/a219aaa53005fa677df3bfd14ede3871/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
[        ] * Try:
[        ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[        ] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 2m 7s

So, I can't install my app in my device (APK)..

Crash when using with Firebase Messaging, because of Application initilalisation.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
E/AndroidRuntime( 5340): 	at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(KeyboardVisibilityPlugin.java:107)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:38)
E/AndroidRuntime( 5340): 	at com.example.app.Application.registerWith(Application.kt:17)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:164)
E/AndroidRuntime( 5340): 	at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:77)
E/AndroidRuntime( 5340): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)

the crash happens in line 107 of https://github.com/adee42/flutter_keyboard_visibility/blob/master/android/src/main/java/com/github/adee42/keyboardvisibility/KeyboardVisibilityPlugin.java

at registrar.activity().getApplication().registerActivityLifecycleCallbacks(instance);
where registrar.activity() return null because registration is happening in Application class, can you have a null check set for this.

application with flutter background view crash

just for information.

if i include your plugin inside a android application who use background flutter view (background service), application crash.

Application crash because a background service call "GeneratedPluginRegistrant.registerWith" with all plugin and your code haven't protection in this case (line 32 in KeyboardVisibilityPlugin)

LOG:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Activity.findViewById(int)' on a null object reference
at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.(KeyboardVisibilityPlugin.java:32)
at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(KeyboardVisibilityPlugin.java:93)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:40)
at com.keyneosoft.keyapp.Application.registerWith(Application.java:19)

yaml file

Add how to add it to the yaml file in your ReadMe file

Ease integration of keyboard listener

Hey,

I have a lot of widgets implementing your listener, very useful. I developed a small mixing through which widgets can implement the listener by changing one line, it does the whole registering and disposing for you if you need just a basic listener. I thought I'd share the code, not sure if you want to add this as some kind of convenience but let me know if you want a PR :)

/// Adds keyboard listener functionality to your State
mixin KeyboardListenerMixin<T extends StatefulWidget> on State<T> {
  final _keyboardListener = KeyboardVisibilityNotification();
  int _keyboardVisibilitySubscriberId;
  bool isKeyboardVisible = false;
  
  @override
  @mustCallSuper
  void initState() {
    super.initState();
    _keyboardVisibilitySubscriberId = _keyboardListener.addNewListener(
      onChange: (bool visible) {
        setState(() {
          isKeyboardVisible = visible;
        });
      },
    );
    // init visibility state
    isKeyboardVisible = _keyboardListener.isKeyboardVisible;
  }

  @override
  @mustCallSuper
  void dispose() {
    _keyboardListener.removeListener(_keyboardVisibilitySubscriberId);
    _keyboardListener.dispose();
    super.dispose();
  }
}

Usage
Add the mixin to your widget state where you want the listener.

class YourStatefulWidgetState extends State<YourStatefulWidget> with KeyboardListenerMixin {

  @override
  Widget build(BuildContext context) {
    if (isKeyboardVisible) return ....something for visible keyboard....;
    return .....something for hidden keyboard....;
  }

}

0.5.6 is broken, back to 0.5.5 works fine

0.5.6 is broken, back to 0.5.5 works fine for me

Flutter (Channel beta, v1.7.8+hotfix.2, on Microsoft Windows [Version 10.0.17134.829], locale zh-TW)
Android devices (Android SDK version 28.0.3)

My app is crashing because of this package

I was told to report this to you:

"Flutter's new background execution feature (described here: https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124) allows plugins to be registered in a background context (e.g. a Service)."

I don't know what this keyboard visibility package does and checked several packages I'm using and can't figure out who is calling it or why, but it's crashing my app, probably because of the warning above. Can you please update your package?

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(KeyboardVisibilityPlugin.java:107)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:37)
at com.onlyup.runsergeant.MainApplication.registerWith(MainApplication.java:18)
at com.ryanheise.audioservice.AudioServicePlugin$BackgroundHandler.onPlay(AudioServicePlugin.java:494)
at com.ryanheise.audioservice.AudioService$MediaSessionCallback$1.run(AudioService.java:536)
at com.ryanheise.audioservice.AudioService$MediaSessionCallback.play(AudioService.java:552)
at com.ryanheise.audioservice.AudioService$MediaSessionCallback.onPlay(AudioService.java:534)
at android.support.v4.media.session.MediaSessionCompat$Callback$StubApi21.onPlay(MediaSessionCompat.java:1405)
at android.support.v4.media.session.MediaSessionCompatApi21$CallbackProxy.onPlay(MediaSessionCompatApi21.java:196)
at android.media.session.MediaSession$CallbackMessageHandler.handleMessage(MediaSession.java:1486)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Unable to get viewInsets.bottom value correctly.

I noticed that the MediaQuery's "viewInsets.bottom" value is always "before" the keyboard show/hide is completed. Thus the value is always "0.00" when "shown" and "non-zero value" when "hidden".

Below is my code:

@override
  void initState() {
    KeyboardVisibilityNotification().addNewListener(
      onChange: (bool visible) {
        double keyboardHeight = getKeyBoardHeight();
        _newScreenHeight = _originalScreenHeight - (visible ? keyboardHeight : 0);
        setState(() {
          _screenHeight = _newScreenHeight;
        });
      },
    );
    super.initState();
  }

  double getKeyBoardHeight() {
    double keyboardHeight = MediaQuery.of(_loginContext).viewInsets.bottom;
    debugPrint("Bottom: "+keyboardHeight.toString());
    return keyboardHeight;
  }

Thank you very much for your effort and time. Appreciates.

Getting MissingPluginException

Here is a stacktrace of my error:

════════ Exception caught by services library ══════════════════════════════════
The following MissingPluginException was thrown while activating platform stream on channel github.com/adee42/flutter_keyboard_visibility:
MissingPluginException(No implementation found for method listen on channel github.com/adee42/flutter_keyboard_visibility)

When the exception was thrown, this was the stack
#0 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:319

#1 EventChannel.receiveBroadcastStream.
package:flutter/…/services/platform_channel.dart:517
#3 EventChannel.receiveBroadcastStream.
package:flutter/…/services/platform_channel.dart:503
#8 new KeyboardVisibilityNotification (package:keyboard_visibility/keyboard_visibility.dart:37:10)

Impossible to build apk on Flutter 1.12.13

Hi,

Thanks for your work on this plugin.
We upgraded Flutter to the latest stable version (1.12.13+hotfix.5) and while our project can run, it cannot build an apk using

flutter build apk

We have this error:

FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Execution failed for task ':keyboard_visibility:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed                                    
     /Users/user/.gradle/caches/transforms-2/files-2.1/7faf2ad74a0b9932e38d86e684646e95/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
                                                                        
     /Users/user/.gradle/caches/transforms-2/files-2.1/7faf2ad74a0b9932e38d86e684646e95/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.

Our projet has been migrated to AndroidX, but the same error appears when I build with the example of this plugin.

Do you know how to resolve this?

onChange event not fired

Hi. This plugin is not working for me.
What I did wrong?
My code is:

@override
void initState() {
  super.initState();

  KeyboardVisibilityNotification().addNewListener(
    onChange: (bool visible) {
      print(visible);
    },
  );
}

And flutter doctor -v:

    • Flutter version 1.12.13+hotfix.8 at /home/spajdo/DevTools/flutter
    • Framework revision 0b8abb4724 (3 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/spajdo/DevTools/android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-R, build-tools 28.0.3
    • ANDROID_HOME = /home/spajdo/DevTools/android-sdk
    • Java binary at: /home/spajdo/DevTools/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
    • All Android licenses accepted.

[✓] Android Studio (version 3.4)
    • Android Studio at /home/spajdo/DevTools/android-studio
    • Flutter plugin version 43.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at /snap/intellij-idea-ultimate/204
    • Flutter plugin version 43.0.3
    • Dart plugin version 193.6494.35

[✓] Connected device (1 available)
    • motorola one zoom • ZY226LTBBQ • android-arm64 • Android 9 (API 28)

• No issues found!

I dont know what can I do to solve this problem.

Package Needs Upgrade

When compiling my app which uses this package, the following error results:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':keyboard_visibility:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

This appears to me to indicate that this package needs to be upgraded to the latest Flutter version.

As you no-doubt know, it's simple to upgrade, just create a new package and copy the dart file over to it.

The application is broken

E/AndroidRuntime( 7962): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getWindowVisibleDisplayFrame(android.graphics.Rect)' on a null object reference
E/AndroidRuntime( 7962): 	at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.onGlobalLayout(KeyboardVisibilityPlugin.java:40)
E/AndroidRuntime( 7962): 	at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
E/AndroidRuntime( 7962): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2290)
E/AndroidRuntime( 7962): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1432)
E/AndroidRuntime( 7962): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6861)
E/AndroidRuntime( 7962): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1026)
E/AndroidRuntime( 7962): 	at android.view.Choreographer.doCallbacks(Choreographer.java:838)
E/AndroidRuntime( 7962): 	at android.view.Choreographer.doFrame(Choreographer.java:769)
E/AndroidRuntime( 7962): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1012)
E/AndroidRuntime( 7962): 	at android.os.Handler.handleCallback(Handler.java:790)
E/AndroidRuntime( 7962): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7962): 	at android.os.Looper.loop(Looper.java:171)
E/AndroidRuntime( 7962): 	at android.app.ActivityThread.main(ActivityThread.java:6651)
E/AndroidRuntime( 7962): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 7962): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/AndroidRuntime( 7962): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

I have 2 screens for oneScree and twoScreen. Twoscreen screen will listen to onkeyboard event,
but when i click on textfield in onescreen app will be stopped.

keyboard visibility breaks with integration of local_auth

Same issue flutter/flutter#55750,

Keyboard_visibility, https://pub.dev/packages/keyboard_visibility breaks, with the integration of local_auth, https://pub.dev/packages/local_auth breaks keyboard listeners.
Steps to reproduce:

  1. Changing FlutterActivity in MainActivity.kt to FlutterFragmentActivity will cause all of the keyboard listeners to break (this is a necessary step in local_auth to be able to detect forms of biometric authentication)
    Breaking code:
package com.example.testing

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterFragmentActivity() {
    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}

Logs for local_auth:

E/flutter (22989): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)
E/flutter (22989): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (22989): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (22989): <asynchronous suspension>
E/flutter (22989): #2      LocalAuthentication.authenticateWithBiometrics (package:local_auth/local_auth.dart:95:27)
E/flutter (22989): #3      _LoginState.authenticateWithBiometrics.<anonymous closure> (package:myapp/login/login.dart:99:48)
E/flutter (22989): #4      new Future.delayed.<anonymous closure> (dart:async/future.dart:316:39)
E/flutter (22989): #5      _rootRun (dart:async/zone.dart:1122:38)
E/flutter (22989): #6      _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (22989): #7      _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (22989): #8      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (22989): #9      _rootRun (dart:async/zone.dart:1126:13)
E/flutter (22989): #10     _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (22989): #11     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
E/flutter (22989): #12     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
E/flutter (22989): #13     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
E/flutter (22989): #14     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
E/flutter (22989): #15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
E/flutter (22989): 

flutter doctor -v

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-US)
    • Flutter version 1.12.13+hotfix.8 at /Users/kendalllu/flutter
    • Framework revision 0b8abb4724 (3 months ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/kendalllu/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.0

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] IntelliJ IDEA Community Edition (version 2019.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] VS Code (version 1.42.1)
    • VS Code at /Users/kendalllu/Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.9.1

onchange event not working for first time

Hi,

I have a device with me i.e Samsung M40 running android 10.

In flutter v 1.12.13 i have created an app using your plugin but the event doesn't fire on first time build and when i run the build again after stopping, it works fine

Doesn't work on web

The package doesn't notice the keyboard VISIBLE on web.
Is this is a bug?
Or is this wrong?
Screenshot 2020-04-29 at 16 47 39

onChange event not always trigger

Today i upgrade my project to flutterEmbedding v2 (before this action, all functional)
onChange event not always been trigger,
don't know if below information related,
help please, thanks.

keyboard_visibility: 0.5.6

Android Error

05-26 22:44:55.706  3387  3387 I KeyboardViewUtil: KeyboardViewUtil.getKeyboardHeightRatio():128 systemKeyboardHeightRatio:1.000000; userKeyboardHeightRatio:1.000000.
05-26 22:44:55.897  3387  3387 I KeyboardViewHelper: KeyboardViewHelper.getView():164 Get view with height ratio:1.000000; experiment height ratio:1.000000.
05-26 22:44:55.989  3387  3387 E KeyboardViewController: KeyboardViewController.show():432 Requesting to show sub view with id 2131428309(key_pos_password_header_numbers) which doesn't exist in current keyboard view
05-26 22:44:55.989  3387  3387 E KeyboardViewController: jsh
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at kev.a(PG:193)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at bps.a(PG:4)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at com.google.android.apps.inputmethod.latin.keyboard.LatinPasswordKeyboard.a(PG:19)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jzc.a(PG:15)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jzc.a(PG:36)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jzb.a(PG:41)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jzc.a(PG:48)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jyq.a(PG:30)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jyq.H(PG:26)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jyu.d(PG:10)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at jyu.b(PG:108)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at com.android.inputmethod.latin.LatinIME.b(PG:337)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at dqg.onStartInputView(PG:779)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.inputmethodservice.InputMethodService.startViews(InputMethodService.java:1955)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1884)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:638)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:220)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.os.Handler.dispatchMessage(Handler.java:107)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.os.Looper.loop(Looper.java:214)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at android.app.ActivityThread.main(ActivityThread.java:7403)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at java.lang.reflect.Method.invoke(Native Method)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
05-26 22:44:55.989  3387  3387 E KeyboardViewController: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
d

Flutter doctor

[✓] Flutter (Channel master, 1.19.0-2.0.pre.143, on Mac OS X 10.15.4 19E287, locale zh-Hant-TW)
    • Flutter version 1.19.0-2.0.pre.143 at /Users/jason/flutter
    • Framework revision 9d58a87066 (3 days ago), 2020-05-22 22:37:01 -0700
    • Engine revision 9ce1e5c5c7
    • Dart version 2.9.0 (build 2.9.0-10.0.dev 7706afbcf5)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/jason/Library/Android/sdk
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /Users/jason/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Connected device (4 available)
    • Mi A2      • 192.168.31.170:5555 • android-arm64  • Android 10 (API 29)
    • macOS      • macOS               • darwin-x64     • Mac OS X 10.15.4 19E287
    • Web Server • web-server          • web-javascript • Flutter Tools
    • Chrome     • chrome              • web-javascript • Google Chrome 81.0.4044.138

Calling setState inside onChange callback causes view reload and keyboard will not open

Has the title if I call setState like your example:

@override
void initState() {
  super.initState();

  _readCredentials();

  _keyboardVisible = _keyboardVisibility.isKeyboardVisible;

  _keyboardVisibilitySubscriberId = _keyboardVisibility.addNewListener(
    onChange: (bool visible) {
      setState(() {
        _keyboardVisible = visible;
      });
    },
  );
}

It cause the view reload and is keyboard immediatly closed.
I'm using the _keyboardVisible flat to show/hide a view.
How could I solve?

The old issue but seems doesn't work. [MissingPluginException]

(As my disappointed English, hoping you can understand my meanning)
Firts, thanks for your package!
It works well on the pure flutter project, but when I use it in a mixed app (add flutter to an existing Android app), it failed, and the message showing in the Run window when open the page:
"Another exception was thrown: MissingPluginException(No implementation found for method listen on channel github.com/adee42/flutter_keyboard_visibility)"
So, are you have any idea about this issue? or the existing solution is wonderful!
Look forward to your favourable reply.

Package does not exists - android

I am facing this issue today

/Users/aravindhkumar/Projects/work_test/testapp/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:5: error: cannot find symbol
import com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin;
                                           ^
  symbol:   class KeyboardVisibilityPlugin
  location: package com.github.adee42.keyboardvisibility

/Users/aravindhkumar/Projects/work_test/testapp/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:19: error: cannot find symbol
    KeyboardVisibilityPlugin.registerWith(registry.registrarFor("com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin"));
    ^
  symbol:   variable KeyboardVisibilityPlugin
  location: class GeneratedPluginRegistrant

can anyone help me to solve with this? I need to deploy the app to play store?

Too much triggers

Is it possible to trigger only a single call when the keyboard is opened/closed? it triggers like 5 or 6 times every keyboard shown/hidden

not work for the 1st time.

Hey, I'm new here. Today I simply git clone the code, and then run the example. No code has been changed.

It didn't work at the fist time, no matter how many times I toggled the keyboard.

But strangely, when I quited the app and entered it again, it worked!

Here's the flutter doctor msg:

[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17763.475], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.33.1)
[√] Connected device (1 available)

A different SOLUTION for those who have problems with events

The events are not triggerred for me for X reasons, but I found a solution for my use case and since I'm not the only one here with this problem...

only for thoses who got TextField(s) in your business logic
You can check if the keyboard is visible or not by the NodeFocus.hasFocus property of your TextField
which have aswell a listener.

YourNodeFocus.addListener(() { print("Has focus: " + _nodeName.hasFocus.toString()); if (YourNodeName.hasFocus) { // keyboard visible } else { // keyboard hidden } });

Scotch solutions.

ref:
https://stackoverflow.com/questions/47965141/how-to-listen-focus-change-in-flutter

The application is suddenly stopped

keyboard_visibility 0.5.6

My application was stopped when I just built it.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
E/AndroidRuntime(23064): 	at com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(KeyboardVisibilityPlugin.java:107)
E/AndroidRuntime(23064): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:39)
E/AndroidRuntime(23064): 	at com.famtech.xeminh.Application.registerWith(Application.java:26)
E/AndroidRuntime(23064): 	at com.famtech.xeminh.bgtracking.GeofencingService.startGeofencingService(GeofencingService.java:71)
E/AndroidRuntime(23064): 	at com.famtech.xeminh.bgtracking.GeofencingService.onCreate(GeofencingService.java:50)
E/AndroidRuntime(23064): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3378)

It is not working on Login Bloc

I'm implementing Login Form with Bloc pattern and I have to manage the size of LoginForm when keyboard is appeared. But It is not working...

import 'package:flutter/material.dart';
import 'package:privacy_of_animal/bloc_helpers/bloc_provider.dart';
import 'package:privacy_of_animal/logics/focus/focus.dart';
import 'package:privacy_of_animal/logics/validation/validation_bloc.dart';
import 'package:privacy_of_animal/resources/colors.dart';
import 'package:privacy_of_animal/resources/constants.dart';
import 'package:privacy_of_animal/widgets/initial_button.dart';
import 'package:keyboard_visibility/keyboard_visibility.dart';

class LoginForm extends StatefulWidget {
  @override
  _LoginFormState createState() => _LoginFormState();
}

class _LoginFormState extends State<LoginForm> with SingleTickerProviderStateMixin{

  final FocusNode _focusNode = FocusNode();
  final ValidationBloc _validationBloc = ValidationBloc();
  final TextEditingController _emailController = TextEditingController();
  final TextEditingController _passwordController = TextEditingController();
  final KeyboardVisibilityNotification _keyboardVisibilityNotification = KeyboardVisibilityNotification();

  @override
    void dispose() {
      _emailController.dispose();
      _passwordController.dispose();
      _focusNode.dispose();
      _keyboardVisibilityNotification.dispose();
      super.dispose();
    }

  @override
  Widget build(BuildContext context) {

    final FocusBloc _focusBloc = BlocProvider.of<FocusBloc>(context);

    _keyboardVisibilityNotification.addNewListener(
      onShow: _focusBloc.emitEvent(FocusEventOn()),
      onHide: _focusBloc.emitEvent(FocusEventOff())
    );

    return Container(
      height: ScreenUtil.height/3,
      width: ScreenUtil.width/1.3,
      color: Colors.red,
      child: Column(
        children: <Widget>[
          StreamBuilder<String>(
            stream: _validationBloc.email,
            builder: (BuildContext context, AsyncSnapshot<String> snapshot){
              return TextField(
                decoration: InputDecoration(
                  labelText: '이메일',
                  errorText: snapshot.error,
                ),
                onChanged: _validationBloc.onEmailChanged,
                keyboardType: TextInputType.emailAddress,
                controller: _emailController,
              );
            },
          ),
          SizedBox(height: 20.0),
          StreamBuilder<String>(
            stream: _validationBloc.password,
            builder: (BuildContext context, AsyncSnapshot<String> snapshot){
              return TextField(
                decoration: InputDecoration(
                  labelText: '비밀번호',
                  errorText: snapshot.error
                ),
                onChanged: _validationBloc.onPasswordChanged,
                obscureText: true,
                keyboardType: TextInputType.emailAddress,
                controller: _passwordController,
              );
            },
          ),
          SizedBox(height: 30.0),
          StreamBuilder<bool>(
            stream: _validationBloc.loginValid,
            builder: (BuildContext context, AsyncSnapshot<bool> snapshot){
              return InitialButton(
                text: '로그인',
                color: introLoginButtonColor,
                callback: (snapshot.hasData && snapshot.data==true) ? (){} : null,
              );
            },
          )
        ],
      ),
    );
  }
}

What is the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.