Giter Club home page Giter Club logo

keyboard_height_plugin's Introduction

Keyboard Height Plugin for Flutter

keyboard_height_plugin is a Flutter plugin for iOS and Android that provides the keyboard size before the keyboard animation occurs for showing or hiding it. This helps eliminate lag when positioning widgets around the keyboard, such as placing a TextField above the keyboard.

Installation

To install keyboard_height_plugin, add it to your pubspec.yaml file under the dependencies section:

dependencies:
  keyboard_height_plugin: ^0.1.5

Usage

To use the keyboard_height_plugin, first import it in your Dart file:

import 'package:keyboard_height_plugin/keyboard_height_plugin.dart';

Next, create a stateful widget and declare a variable to store the keyboard height and create an instance of the KeyboardHeightPlugin:

class _HomePageState extends State<HomePage>; {
  double _keyboardHeight = 0;
  final KeyboardHeightPlugin _keyboardHeightPlugin = KeyboardHeightPlugin();
  // ... rest of code ...
}

Then, initialize the KeyboardHeightPlugin in your initState method and listen for changes in the keyboard height:

@override
void initState() {
  super.initState();
  _keyboardHeightPlugin.onKeyboardHeightChanged((double height) {
    setState(() {
      _keyboardHeight = height;
    });
  });
}

Use the _keyboardHeight variable to position your widgets around the keyboard.

Example

For a complete example on how to use the keyboard_height_plugin, please refer to the example directory in the repository.

Contributing

If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the project's GitHub repository.

License

This plugin is licensed under the BSD 3-Clause License.

keyboard_height_plugin's People

Contributors

nschairer avatar penkzhou avatar q200892907 avatar

Stargazers

Niloy Biswas avatar Luy2077 avatar tianshui avatar Francisco Pitriqueo avatar Jason Elder avatar ttoe avatar  avatar  avatar

Watchers

 avatar  avatar

keyboard_height_plugin's Issues

Package throws runtime error

The package throws this error at runtime:

======== Exception caught by services library ======================================================
The following MissingPluginException was thrown while activating platform stream on channel keyboardHeightEventChannel:
MissingPluginException(No implementation found for method listen on channel keyboardHeightEventChannel)

When the exception was thrown, this was the stack:
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)

#1 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:652:9)

I even cloned the repo and re-ran. Same result.

Please what could be wrong?

[iOS] decrease height value if text suggestion is disabled

@nschairer Hello!
Thanks for this plugin, we currently use it in Presence to workaround flutter janks when keyboard is opened.
Basically, we calculate keyboard height and animated the UI manually during keyboard animation.

However, we just noticed that the height value is not correct if user disabled the text suggestion (the text suggestion row's height is still added to keyboard height).

Can you please have a look at this?

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.