Search packages, repositories and app categories

Package detailsv0.3.0

keyboard_height_plugin

Flutter plugin that emits keyboard height before it shows (ios/android)

AndroidiOS
30-day downloads
41K
Likes
31
Pub points
150

Install package

flutter pub add keyboard_height_plugin

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The keyboard_height_plugin is a Flutter package that provides real-time updates on the height of the on-screen keyboard before it appears on Android and iOS devices. It emits the keyboard height as it's about to be displayed, enabling developers to adjust UI layouts dynamically for better user experience. This plugin is particularly useful for forms or input fields where content might be obscured by the keyboard. It works seamlessly across both major mobile platforms and integrates easily via pub.dev. The plugin is lightweight and focused solely on keyboard height detection without additional features.

Use cases

  • Dynamic form layout adjustment
  • Preventing input field overlap
  • Real-time UI responsiveness
  • Mobile app keyboard awareness
  • Optimizing screen space during input

Key features

  • Emits keyboard height before display
  • Cross-platform (Android & iOS)
  • Lightweight and focused
  • Simple integration via pub.dev
  • No extra dependencies

Suitable for

  • Developers building input-heavy apps
  • Apps requiring responsive UIs
  • Form-based mobile applications
  • Projects needing precise keyboard feedback
  • Flutter apps targeting both iOS and Android

Considerations

  • Requires manual handling of layout changes
  • Limited to keyboard height only
  • Does not support custom keyboards
  • No built-in animation support
  • May need additional state management

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Requirements

Version 0.3.0+ (Current)
  • Android:
    • Android Gradle Plugin (AGP) 8.6.0+
    • Gradle 8.7+
    • Kotlin 2.1.0+
    • Java 17+
    • minSdkVersion 16 (Android 4.1+)
    • compileSdkVersion 34+
  • iOS:
    • iOS 12.0+
    • Supports both CocoaPods and Swift Package Manager
    • Includes Privacy Manifest for App Store compliance
Version 0.1.5 (Legacy Support)

For projects that cannot upgrade to the modern build tools, use version 0.1.5:

  • Android Gradle Plugin 7.x
  • Kotlin 1.7.x
  • Java 11+

Installation

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

dependencies:
  keyboard_height_plugin: ^0.3.0

For legacy projects:

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.

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.0.2

Source repository

Projects using this package