Package selection guidance compiled from public package information, community data, and project usage.
The keyboard_detection package is a Flutter plugin that simplifies the detection of keyboard visibility by monitoring the bottom view inset. It provides a reliable way to determine when the keyboard appears or disappears on various platforms, including Android, iOS, Web, macOS, Windows, and Linux. This helps developers adjust UI layouts dynamically for better user experience during input interactions. The plugin integrates seamlessly with existing Flutter apps and requires minimal setup. It's particularly useful in forms, chat interfaces, and any scenario where responsive layout adjustments are needed based on keyboard state.
Use cases
Dynamic form layout adjustment
Chat interface responsiveness
Input field focus management
Responsive UI for mobile and desktop
Handling keyboard overlaps
Auto-scrolling to focused fields
Key features
Detects keyboard visibility via bottom view inset
Cross-platform support (Android, iOS, Web, macOS, Windows, Linux)
Simple API integration
Real-time keyboard state updates
Minimal configuration required
Works with both physical and on-screen keyboards
Suitable for
Flutter developers building input-heavy apps
Apps requiring adaptive UI layouts
Developers targeting multiple platforms
Projects with dynamic form or chat interfaces
Teams seeking lightweight keyboard detection
Considerations
May require additional handling for complex nested scroll views
Not suitable for detecting keyboard height directly
Behavior may vary slightly across different platform implementations
Best used with Scaffold or similar layout structures
Limited to keyboard visibility; does not detect keyboard type or language
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Keyboard Detection
Easily detect keyboard visibility in your Flutter app with this plugin. It leverages the resizing of the bottom view inset to determine keyboard visibility, ensuring a native Flutter experience.
keyboardDetectionController.state: Get the current keyboard visibility state as a KeyboardState enum.
keyboardDetectionController.stateAsBool([bool includeTransitionalState = false]): Get the keyboard visibility as a bool?. If includeTransitionalState is true, transitional states (visibling, hiding) are included.
keyboardDetectionController.addCallback(callback): Add a callback for state changes. Return true for repeated calls, false to stop.
keyboardDetectionController.stream: Listen to keyboard visibility changes as a stream.
keyboardDetectionController.size: Get the keyboard size. Use keyboardDetectionController.ensureSizeLoaded to ensure the size is loaded.
Limitations
This package uses the bottom inset to detect keyboard visibility, so it doesn't work with floating keyboards (Issue #1).
Contributions
Contributions and feedback are welcome! Feel free to open issues or submit pull requests.