From a6d72199921aea4bdac955a8aa1b045ea7f0ac88 Mon Sep 17 00:00:00 2001 From: Noah Schairer Date: Fri, 28 Apr 2023 16:12:19 -0400 Subject: [PATCH] Update README.md --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4117778..e9d455a 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,58 @@ -# keyboard_height_plugin +# Keyboard Height Plugin for Flutter -A new Flutter plugin project. +`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. -## Getting Started +## Installation -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. +To install `keyboard_height_plugin`, add it to your `pubspec.yaml` file under the `dependencies` section: -For help getting started with Flutter development, view the -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +```yaml +dependencies: + keyboard_height_plugin: ^0.0.2 +``` -# keyboard_height_plugin +## Usage + +To use the `keyboard_height_plugin`, first import it in your Dart file: + +```dart +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`: + +```dart +class _HomePageState extends State; { + 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: + +```dart +@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`](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](LICENSE).