GithubHelp home page GithubHelp logo

isaiassantana / keyboard_utils Goto Github PK

View Code? Open in Web Editor NEW
49.0 5.0 48.0 487 KB

A Flutter plugin to check keyboard visibility.

License: MIT License

Kotlin 29.49% Ruby 8.01% Swift 16.08% Objective-C 1.09% Dart 45.33%

keyboard_utils's Introduction

keyboard_utils

A Flutter plugin to check keyboard visibility and height.

Licence

sample

Install

Follow this guide

How to use

Add the imports:

import 'package:keyboard_utils/keyboard_utils.dart';
import 'package:keyboard_utils/keyboard_listener.dart';

Create the KeyboardUtils:

KeyboardUtils  _keyboardUtils = KeyboardUtils();

Attach the listener to KeyboardUtils:

final int _idKeyboardListener = _keyboardUtils.add(
        listener: KeyboardListener(willHideKeyboard: () {
      // Your code here
    }, willShowKeyboard: (double keyboardHeight) {
      // Your code here
    }));

Remember call dispose:

_keyboardUtils.unsubscribeListener(subscribingId: _idKeyboardListener);
    if (_keyboardUtils.canCallDispose()) {
      _keyboardUtils.dispose();
    }

Instead, you can also use KeyboardAware Widget:

 import 'package:keyboard_utils/widgets.dart';
 
 ....
 
 Widget buildSampleUsingKeyboardAwareWidget() {
    return Center(
      child: Column(
        children: <Widget>[
          TextField(),
          TextField(
            keyboardType: TextInputType.number,
          ),
          TextField(),
          SizedBox(
            height: 30,
          ),
          KeyboardAware(
            builder: (context, keyboardConfig) {
              return Text('is keyboard open: ${keyboardConfig.isKeyboardOpen}\n'
                  'Height: ${keyboardConfig.keyboardHeight}');
            },
          ),
        ],
      ),
    );
  }
  
  ....

To share KeyboardConfig in your widget tree, use the KeyboardConfigInheritedWidget widget.

Check the sample for more details.

Authors

Isaías Santana
Isaías Santana
Will Filho
Will Filho

keyboard_utils's People

Contributors

drarox avatar isaiassantana avatar marcglasberg avatar noordawod avatar wilfilho 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

Watchers

 avatar  avatar  avatar  avatar  avatar

keyboard_utils's Issues

Not working on iOS with error

I tried building and running on iOS and I get the below error logs

Failed to build iOS app
Error output from Xcode build:
↳
    2020-05-10 20:26:29.576 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver’s iPhone, iPhone, 13.3.1 (17D50), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> == Underlying device preparation errors ==
    2020-05-10 20:26:29.576 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver's iPhone, iPhone, 13.0 (17A577), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> -- Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.
    Domain: com.apple.platform.iphoneos
    Code: 5
    Failure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x7f81e542a4c0:'com.apple.platform.iphoneos':<DVTFilePath:0x7f81e542a440:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform'>>. DTDKDeviceIdentifierIsIDID: 0
    --
    2020-05-10 20:26:29.576 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver’s iPhone, iPhone, 13.3.1 (17D50), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> == END: Underlying device preparation errors ==
    2020-05-10 20:26:29.665 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver’s iPhone, iPhone, 13.3.1 (17D50), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> == Underlying device preparation errors ==
    2020-05-10 20:26:29.665 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver's iPhone, iPhone, 13.0 (17A577), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> -- Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.
    Domain: com.apple.platform.iphoneos
    Code: 5
    Failure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x7f81e542a4c0:'com.apple.platform.iphoneos':<DVTFilePath:0x7f81e542a440:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform'>>. DTDKDeviceIdentifierIsIDID: 0
    --
    2020-05-10 20:26:29.665 xcodebuild[3314:38519] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7f81d54a1680), Oliver’s iPhone, iPhone, 13.3.1 (17D50), b3d99ff4ed9f1a1a3aa41eb597b33b6ddc7d2752> == END: Underlying device preparation errors ==
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/nemoryoliver/Development/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.1/ios/Classes/SwiftKeyboardUtilsPlugin.swift:49:66: error: 'keyboardWillShowNotification' has been renamed to 'NSNotification.Name.UIKeyboardWillShow'
                                                   name: UIResponder.keyboardWillShowNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardWillShow
    UIKit.UIResponder:3:22: note: 'keyboardWillShowNotification' was introduced in Swift 4.2
        public class let keyboardWillShowNotification: NSNotification.Name
                         ^
    /Users/nemoryoliver/Development/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.1/ios/Classes/SwiftKeyboardUtilsPlugin.swift:54:66: error: 'keyboardWillHideNotification' has been renamed to 'NSNotification.Name.UIKeyboardWillHide'
                                                   name: UIResponder.keyboardWillHideNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

fatal error: 'keyboard_utils/keyboard_utils-Swift.h' file not found #import <keyboard_utils/keyboard_utils-Swift.h>

Hi,
I am suprisingly start to get this error at title.
My ios version 14.3, xcode 12.3
I tried new build system and legacy build system but no success. I could not get what the problem is. here is the build log.

  /Users/bilalsimsek/DevelopmentTools/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.4/ios/Classes/KeyboardUtilsPlugin.m:2:9: fatal error: 'keyboard_utils/keyboard_utils-Swift.h' file not found
    #import <keyboard_utils/keyboard_utils-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    Command CompileSwift failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.

 

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

public class SwiftKeyboardUtilsPlugin: NSObject, FlutterPlugin ,FlutterStreamHandler {
private var eventSink: FlutterEventSink?
private var isKeyboardOpen = false
private var previewsKeyboardHeight = 0.0

public override init() {
    super.init()

    registerEvents()
}

public static func register(with registrar: FlutterPluginRegistrar) {
    let eventChannel = FlutterEventChannel(name: "keyboard_utils", binaryMessenger: registrar.messenger())
    let instance = SwiftKeyboardUtilsPlugin()
    eventChannel.setStreamHandler(instance)
}

......

registrar is null

Unable to determine Swift version for the following pods

When run app on ios simulator with this plugin. pod install says:
[!] Unable to determine Swift version for the following pods:
- keyboard_utils does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

flutter doctor:
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15.2 19C57, locale zh-Hans-CN)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
[✓] VS Code (version 1.40.2)
[✓] Connected device (1 available)

NNBD support?

Hi! I'm trying to upgrade our projects to latest flutter / dart with NNBD but this package does not support it yet. Any plans to update?

UIKeyboardWillShow has been renamed to 'UIResponder.keyboardWillShowNotification'

1.3.4

[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale
    zh-Hans-CN)
    • Flutter version 2.8.1 at /Users/tian/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (4 个月前), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/tian/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /Users/tian/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.53.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • hehe的iPhone (mobile) • 00008030-000D583C2651802E • ios • iOS 15.3.1 19D52

• No issues found!


Listeners get deleted when you add new ones

There is a bug here:

  /// Subscribe to a keyboard event.
  /// [listener] object to listen the event.
  /// Returns a subscribing id that can be used to unsubscribe.
  int add({required KeyboardListener listener}) {
    final int length = _listenersKeyboardEvents.length;
    _listenersKeyboardEvents[length] = listener;
    return length;
  }

If you add one listener listener1 (length is 0, becomes 1):

{0: listener1}

Then add a second listener listener2 (length is 1, becomes 2):

{0: listener1, 1: listener2}

Then remove the one with id 0 (length is 2, becomes 1):

{1: listener2}

But now if you add a third listener listener3, since length is now 1, it will overwrite listener2, and you'd get:

{1: listener3}

The solution is creating an independent counter that never repeats:

static int _count = 0;

  /// Subscribe to a keyboard event.
  /// [listener] object to listen the event.
  /// Returns a subscribing id that can be used to unsubscribe.
  int add({required KeyboardListener listener}) {
    _listenersKeyboardEvents[_count] = listener;
    _count++;
    return _count;
  }

Android build error:Kotlin Gradle plugin version 1.3.0 and higher

FAILURE: Build failed with an exception.

  • What went wrong:
    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
    The following dependencies do not satisfy the required version:
    project ':keyboard_utils' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71

iOS compilation errors : Constants renamed

Hello,

I use keyboard_utils v1.2.0 on a Flutter (kotlin/Swift) project.

On build, Xcode returns the following output :

Command CompileSwift failed with a nonzero exit code
    /.../flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:49:66: error: 'keyboardWillShowNotification' has been renamed to 'NSNotification.Name.UIKeyboardWillShow'
                                                   name: UIResponder.keyboardWillShowNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardWillShow
    UIKit.UIResponder:3:22: note: 'keyboardWillShowNotification' was introduced in Swift 4.2
        public class let keyboardWillShowNotification: NSNotification.Name
                         ^
    /.../flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:54:66: error: 'keyboardWillHideNotification' has been renamed to 'NSNotification.Name.UIKeyboardWillHide'
                                                   name: UIResponder.keyboardWillHideNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardWillHide
    UIKit.UIResponder:7:22: note: 'keyboardWillHideNotification' was introduced in Swift 4.2
        public class let keyboardWillHideNotification: NSNotification.Name
                         ^
    /.../flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:59:66: error: 'keyboardDidShowNotification' has been renamed to 'NSNotification.Name.UIKeyboardDidShow'
                                                   name: UIResponder.keyboardDidShowNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardDidShow
    UIKit.UIResponder:5:22: note: 'keyboardDidShowNotification' was introduced in Swift 4.2
        public class let keyboardDidShowNotification: NSNotification.Name
                         ^
    /.../flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:73:80: error: 'keyboardFrameEndUserInfoKey' has been renamed to 'UIKeyboardFrameEndUserInfoKey'
                if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                   UIKeyboardFrameEndUserInfoKey
    UIKit.UIResponder:15:22: note: 'keyboardFrameEndUserInfoKey' was introduced in Swift 4.2
        public class let keyboardFrameEndUserInfoKey: String

'keyboard_utils/keyboard_utils-Swift.h' file not found

Hi there!
I get the following error on iOS:

Could not build the precompiled application for the device.
Uncategorized (Xcode): Command CompileSwiftSources failed with a nonzero exit code

Lexical or Preprocessor Issue (Xcode): 'keyboard_utils/keyboard_utils-Swift.h' file not found
/usr/local/Caskroom/flutter/2.10.4/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.3.4/ios/Classes/KeyboardUtilsPlugin.m:1:8

Error launching application on iPhone X.

not work on Android with flutter 1.17

After upgrade flutter to version 1.17 today, i found keyboard change is not working properly with android project (on emulator).

with both KeyboardListener & KeyboardAware ( i tried both)

xcode 11.3 errors keyboardWillShowNotification has been renamed to NSNotification.Name.UIKeyboardWillShow

I don't have keyboard_utils in my pubspec.yaml so anther plugin must be pulling it in. I'm seeing the errors below in both InteliJ and Xcode 11.3. Can you put a fix out?

                                                   name: UIResponder.keyboardWillShowNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardWillShow
    UIKit.UIResponder:3:22: note: 'keyboardWillShowNotification' was introduced in Swift 4.2
        public class let keyboardWillShowNotification: NSNotification.Name
                         ^
    /Users/tim/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:54:66: error: 'keyboardWillHideNotification' has been renamed to 'NSNotification.Name.UIKeyboardWillHide'
                                                   name: UIResponder.keyboardWillHideNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardWillHide
    UIKit.UIResponder:7:22: note: 'keyboardWillHideNotification' was introduced in Swift 4.2
        public class let keyboardWillHideNotification: NSNotification.Name
                         ^
    /Users/tim/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:59:66: error: 'keyboardDidShowNotification' has been renamed to 'NSNotification.Name.UIKeyboardDidShow'
                                                   name: UIResponder.keyboardDidShowNotification,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                     NSNotification.Name.UIKeyboardDidShow
    UIKit.UIResponder:5:22: note: 'keyboardDidShowNotification' was introduced in Swift 4.2
        public class let keyboardDidShowNotification: NSNotification.Name
                         ^
    /Users/tim/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:73:80: error: 'keyboardFrameEndUserInfoKey' has been renamed to 'UIKeyboardFrameEndUserInfoKey'
                if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                   UIKeyboardFrameEndUserInfoKey
    UIKit.UIResponder:15:22: note: 'keyboardFrameEndUserInfoKey' was introduced in Swift 4.2
        public class let keyboardFrameEndUserInfoKey: String```

Saber qual tipo de teclado está aberto?

Seria possível saber qual o tipo de teclado que está aberto? Por exemplo, se o teclado aberto é o teclado numérico, ou o teclado qwerty comum? No builder poderia ter mais um parâmetro:

enum KeyboardType {numerical, qwerty, other}

class KeyboardOptions {
  KeyboardOptions({required this.isKeyboardOpen, required this.keyboardHeight});

  final bool isKeyboardOpen;
  final double keyboardHeight;
  final KeyboardType keyboardType;
...

the height is not corrent

in some new oppo vivo mate20 phone, can get the height ,but the height value is not correct,or high or low

Keyboard height is wrong on Android

Hi there!
The keyboard height I get from your library seems to be wrong. The value is 30 logical pixels too low I think. For visualization I created a Container that sits behind the keyboard thank to an OffStage widget and resizeToAvoidBottomInset: false,

Here a minimum reproducible example that is based on your example:

import 'dart:async';

import 'package:flutter/material.dart';

import 'package:keyboard_utils/keyboard_utils.dart';
import 'package:keyboard_utils/keyboard_listener.dart' as keyboard_listener;
import 'package:keyboard_utils/widgets.dart';

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

// Sample Bloc
class KeyboardBloc {
  KeyboardUtils _keyboardUtils = KeyboardUtils();
  StreamController<double> _streamController = StreamController<double>();
  Stream<double> get stream => _streamController.stream;

  KeyboardUtils get keyboardUtils => _keyboardUtils;

  int _idKeyboardListener;

  void start() {
    _idKeyboardListener = _keyboardUtils.add(
        listener: keyboard_listener.KeyboardListener(willHideKeyboard: () {
      print('willHideKeyboard: ${_keyboardUtils.keyboardHeight}');
      _streamController.sink.add(_keyboardUtils.keyboardHeight);
    }, willShowKeyboard: (double keyboardHeight) {
      print('willShowKeyboard: $keyboardHeight');
      print('ratio: ${WidgetsBinding.instance.window.devicePixelRatio}');
      print('view padding: ${WidgetsBinding.instance.window.viewPadding}');
      _streamController.sink.add(keyboardHeight);
    }));
  }

  void dispose() {
    _keyboardUtils.unsubscribeListener(subscribingId: _idKeyboardListener);
    if (_keyboardUtils.canCallDispose()) {
      _keyboardUtils.dispose();
    }
    _streamController.close();
  }
}

// App
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  KeyboardBloc _bloc = KeyboardBloc();

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

    _bloc.start();
  }

  Widget buildSampleUsingKeyboardAwareWidget() {
    return Center(
      child: Column(
        children: <Widget>[
          TextField(),
          TextField(
            keyboardType: TextInputType.number,
          ),
          TextField(),
          SizedBox(
            height: 30,
          ),
          KeyboardAware(
            builder: (context, keyboardConfig) {
              return Text('is keyboard open: ${keyboardConfig.isKeyboardOpen}\n'
                  'Height: ${keyboardConfig.keyboardHeight}');
            },
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          title: const Text('Keyboard Utils Sample'),
        ),
        body: Column(
          children: [
            Expanded(
              child: Column(
                children: [
                  buildSampleUsingKeyboardAwareWidget(),
                  Expanded(child: Container()),
                  Container(
                    height: 10.0,
                    color: Colors.green,
                  ),
                ],
              ),
            ),
            StreamBuilder<double>(
              stream: _bloc.stream,
              builder: (context, snapshot) => Offstage(
                offstage: !_bloc.keyboardUtils.isKeyboardOpen,
                child: SizedBox(
                  height: _bloc.keyboardUtils.keyboardHeight + 30, // TODO where does this offset came from?
                  child: Container(color: Colors.red),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

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

This example only works an my Android 10 device (Xiaomi Mi A2 Lite) if I use _bloc.keyboardUtils.keyboardHeight + 30 instead of the normal height.
I afraid that this value is different for each device. Is there a way to fix this? @IsaiasSantana @wilfilho

1.3.3 compile error in xcode

 /Users/tian/.pub-cache/hosted/pub.flutter-io.cn/keyboard_utils-1.3.3/ios/Classes/SwiftKeyboardUtilsPlugin.swift:73:68: error: 'UIKeyboardFrameEndUserInfoKey' has been renamed to 'UIResponder.keyboardFrameEndUserInfoKey'
                if let keyboardFrame: NSValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                       UIResponder.keyboardFrameEndUserInfoKey
    UIKit.UIKeyboardFrameEndUserInfoKey:3:12: note: 'UIKeyboardFrameEndUserInfoKey' was obsoleted in Swift 4.2
    public let UIKeyboardFrameEndUserInfoKey: String
               ^
    Command CompileSwiftSources failed with a nonzero exit code
    Command CompileSwiftSources failed with a nonzero exit code
╰─➤  flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.5.2 20G95 darwin-x64, locale
    zh-Hans-CN)
    • Flutter version 2.8.1 at /Users/tian/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (5 周前), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/tian/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /Users/tian/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.53.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • hehe的iPhone (mobile) • 00008030-000D583C2651802E • ios • iOS 14.4.2 18D70

• No issues found!

Swift Version issue

/keyboard_utils/ios/Classes/SwiftKeyboardUtilsPlugin.swift:59:66: error: 'keyboardDidShowNotification' has
been renamed to 'NSNotification.Name.UIKeyboardDidShow'
name: UIResponder.keyboardDidShowNotification,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
NSNotification.Name.UIKeyboardDidShow
UIKit.UIResponder:5:22: note: 'keyboardDidShowNotification' was introduced in Swift 4.2

Force close

with this error

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.MainActivity}: java.lang.UnsupportedOperationException: The new embedding does not support the old FlutterView. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2449) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2509) at android.app.ActivityThread.access$1000(ActivityThread.java:153) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:5527) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) Caused by: java.lang.UnsupportedOperationException: The new embedding does not support the old FlutterView. at io.flutter.embedding.engine.plugins.shim.ShimRegistrar.view(ShimRegistrar.java:82) at br.com.keyboard_utils.KeyboardUtilsPlugin$Companion.registerWith(KeyboardUtilsPlugin.kt:16) at br.com.keyboard_utils.KeyboardUtilsPlugin.registerWith(KeyboardUtilsPlugin.kt) at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:20) at com.tes.MainActivity.configureFlutterEngine(MainActivity.kt:10) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:185) at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:418) at android.app.Activity.performCreate(Activity.java:6303) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2402) ... 9 more

Build is called multiple times on keyboard coming up and going down

Hi,

Package is working very well. But we are facing this issue of multiple times refreshing / build of the call being called multiple times. Because of this

Performance issues are coming in

Not able to do the animation as it is being called multiple times. Looks jerky..

Could not build iOS App

/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:49:66: error: type 'UIResponder' has no member 'NSNotification'
name: UIResponder.NSNotification.Name.UIKeyboardWillShow,
~~~~~~~~~~~ ^~~~~~~~~~~~~~
/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:54:66: error: type 'UIResponder' has no member 'NSNotification'
name: UIResponder.NSNotification.Name.UIKeyboardWillHide,
~~~~~~~~~~~ ^~~~~~~~~~~~~~
/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:59:66: error: type 'UIResponder' has no member 'NSNotification'
name: UIResponder.NSNotification.Name.UIKeyboardDidShow,
~~~~~~~~~~~ ^~~~~~~~~~~~~~
/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.2.0/ios/Classes/SwiftKeyboardUtilsPlugin.swift:73:80: error: type 'UIResponder' has no member 'UIKeyboardFrameEndUserInfoKey'
if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.UIKeyboardFrameEndUserInfoKey] as? NSValue {

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.17.0, on Mac OS X 10.15.3 19D76, locale de-DE)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
[!] Android Studio (version 3.6)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.44.0)
[!] Connected device
! No devices available

! Doctor found issues in 2 categories.

Issues with latest Flutter version

getting the following error:

'KeyboardListener' isn't a function. (Documentation) Try correcting the name to match an existing function, or define a method or function named 'KeyboardListener'.
The name 'KeyboardListener' is defined in the libraries 'package:flutter/src/widgets/keyboard_listener.dart' and 'package:keyboard_utils/keyboard_listener.dart'. (Documentation) Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.

Flutter doctor:
[✓] Flutter (Channel beta, 2.6.0-5.2.pre, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-CA)
• Flutter version 2.6.0-5.2.pre at /Users/pazhutmann/Work/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 400608f101 (17 hours ago), 2021-09-15 15:50:26 -0700
• Engine revision 1d521d89d8
• Dart version 2.15.0 (build 2.15.0-82.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/pazhutmann/Library/Android/sdk
• Platform android-29, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.1

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

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

Not working at all on emulator and partly on physical device - Android

Hi,

I used the package and it worked great!
Then I changed flutter version and it is working not good now.

[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.19041.264], locale en-IL)
    • Flutter version 1.17.1 at C:\Installations\flutter
    • Framework revision f7a6a7906b (5 days ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\omri1\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.44.2)
    • VS Code at C:\Users\omri1\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.8.1

[√] Connected device (2 available)
    • SM G970F            • RF8M21HY5MZ   • android-arm64 • Android 10 (API 29)
    • AOSP on IA Emulator • emulator-5554 • android-x86   • Android 9 (API 28) (emulator)

• No issues found!

I used it as regular. the event _onKeyboardListener is not called when the keyboard is closing on my Galaxy S10e and not called at all on my emulator.

Thank you!

Project does not run with new Flutter 2.10.0

After I updated the Flutter from v2.8.1 to v.2.10.0 my app does not run on both macOS and Windows (proven by other colleagues). Running commands like flutter clean and flutter doctor is not solving the issue - the app is still not able to run.

I tried to manually fix this line mentioned in the warning but it seemed not helped.

e: /Users/andreifufylev/development/flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_utils-1.3.3/android/src/main/kotlin/br/com/keyboard_utils/manager/KeyboardUtils.kt: (56, 40): Using 'max(): T?' is an error. Use maxOrNull instead.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':keyboard_utils:compileDebugKotlin'.
> Compilation error. See log for more details

* 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 24s
Exception: Gradle task assembleDevelopmentDebug failed with exit code 1

Null Safe Version

Hi

i would like to know your plans with regards to provide null safe version of the plugin. seems Dart is moving to this and this becomes a standard

Thanks
P

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.