keyboard_safe 0.0.1 copy "keyboard_safe: ^0.0.1" to clipboard
keyboard_safe: ^0.0.1 copied to clipboard

A lightweight Flutter widget that prevents keyboard overflow by automatically adjusting layout, scrolling input fields into view, and providing sticky footers above the keyboard.

๐Ÿ“ฑ keyboard_safe #

A lightweight Flutter widget that prevents keyboard overflow by automatically adjusting padding and optionally scrolling input fields into view.

pub package


โœ… Why KeyboardSafe? #

Flutter apps often struggle with keyboard handling, especially in complex forms.
KeyboardSafe solves this with a single, configurable wrapper that offers:

  • โœ… Automatically adjusts padding when the keyboard appears
  • ๐ŸŽฏ Auto-scrolls to focused input fields
  • ๐Ÿ“Œ Optional sticky footer support above the keyboard
  • ๐Ÿ‘† Tap outside to dismiss keyboard
  • ๐Ÿ“ฆ Optional SafeArea wrapping
  • ๐ŸŽฌ Smooth animated transitions

๐Ÿ”ง Install it #

Add it to your pubspec.yaml:

dependencies:
  keyboard_safe: ^0.0.1

Then run:

flutter pub get

๐Ÿ”จ Usage #

Wrap your form or layout with KeyboardSafe:

import 'package:keyboard_safe/keyboard_safe.dart';

@override
Widget build(BuildContext context) {
  return KeyboardSafe(
    scroll: true,
    dismissOnTapOutside: true,
    footer: ElevatedButton(
      onPressed: () {},
      child: const Text('Submit'),
    ),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: const [
        TextField(decoration: InputDecoration(labelText: 'Email')),
        SizedBox(height: 16),
        TextField(decoration: InputDecoration(labelText: 'Password')),
      ],
    ),
  );
}

๐Ÿ“ฑ Example App #

The example/ app demonstrates the benefits of using KeyboardSafe:

โœ… Includes a toggle for 'With' vs 'Without KeyboardSafe'
โœ… Demonstrates auto-scroll to input, sticky footer, keyboard avoidance, and tap-outside dismissal

To run:

flutter run example

๐Ÿ“ฆ Parameters #

Parameter Type Default Description
child Widget โ€” (required) Main content inside the wrapper
footer Widget? null Optional footer shown above the keyboard (e.g. Submit button)
scroll bool false Whether to wrap in SingleChildScrollView
autoScrollToFocused bool true Automatically scroll focused field into view
dismissOnTapOutside bool false Tap anywhere to dismiss keyboard
safeArea bool false Wrap in a SafeArea widget
persistFooter bool false Whether footer should remain visible when keyboard appears
padding EdgeInsets EdgeInsets.zero Base padding applied before keyboard adjustment
reverse bool false Reverses scroll direction
onKeyboardChanged void Function(bool, double)? null Callback when keyboard appears/disappears
keyboardAnimationDuration Duration Duration(milliseconds: 250) Duration of keyboard transitions
keyboardAnimationCurve Curve Curves.easeOut Curve used in AnimatedPadding and AnimatedContainer

โŒจ๏ธ Dismiss Keyboard #

You can programmatically dismiss the keyboard using:

KeyboardSafe.dismissKeyboard(context);

๐Ÿงช Testing #

This package includes widget tests that verify key behaviors:

flutter test

Covered features:

โœ… Padding applied when MediaQuery.viewInsets.bottom is non-zero
โœ… Keyboard dismissal when tapping outside of input


๐Ÿ“„ License #

MIT License. See LICENSE for details.


๐Ÿ’ก Contribute #

Feel free to file issues or submit PRs to help improve this package.
Star โญ the repo if you found this helpful!


๐Ÿ’ฌ Maintainer #

Made by @ChathraNavoda

19
likes
0
points
584
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter widget that prevents keyboard overflow by automatically adjusting layout, scrolling input fields into view, and providing sticky footers above the keyboard.

Repository (GitHub)
View/report issues

Topics

#keyboard #layout #textfields #overflow #focus

License

unknown (license)

Dependencies

flutter

More

Packages that depend on keyboard_safe