Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyboard visibility breaks with integration of local_auth #61

Open
kendall-lu opened this issue May 4, 2020 · 4 comments
Open

keyboard visibility breaks with integration of local_auth #61

kendall-lu opened this issue May 4, 2020 · 4 comments

Comments

@kendall-lu
Copy link

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
@viktor-morin
Copy link

I just got stuck on the same issue, any suggestions?

@kendall-lu
Copy link
Author

kendall-lu commented May 15, 2020

I just got stuck on the same issue, any suggestions?

Hey, i ended up creating a work around ( i noticed that the only times a keyboard shows up is when a TextField is focused). In my initState i checked whether the Platform.isAndroid, in that condition I added listeners to my focusNodes and checked whether any one of my focusNode.hasFocus. By no means is this a catch all solution.

 if (Platform.isAndroid) {

      focusNode1.addListener((){
        // Your listener here
      });
    } else {
      KeyboardVisibilityNotification().addNewListener(
      onChange: (bool visible) {
        setState((){
          isKeyboardVisible = visible;
        });
      },
    );
    }

@viktor-morin
Copy link

I just got stuck on the same issue, any suggestions?

Hey, i ended up creating a work around ( i noticed that the only times a keyboard shows up is when a TextField is focused). In my initState i checked whether the Platform.isAndroid, in that condition I added listeners to my focusNodes and checked whether any one of my focusNode.hasFocus. By no means is this a catch all solution.

 if (Platform.isAndroid) {

      focusNode1.addListener((){
        // Your listener here
      });
    } else {
      KeyboardVisibilityNotification().addNewListener(
      onChange: (bool visible) {
        setState((){
          isKeyboardVisible = visible;
        });
      },
    );
    }

The reason why I use this package is that you can have a general listner on the event when the keyboard is shown, otherwise I need to setup all textfields and their focusnode. It kind of work against the purpose if this package right?

@viktor-morin
Copy link

viktor-morin commented Jun 17, 2020

Flutter Keyboard Visibility

@kendall-lu
Same issue is now resolved for package mention above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants