keyboard_inset_avoider 0.1.0 copy "keyboard_inset_avoider: ^0.1.0" to clipboard
keyboard_inset_avoider: ^0.1.0 copied to clipboard

PlatformAndroid

Reliable keyboard inset fallback and bottom-bar avoidance widgets for Flutter.

keyboard_inset_avoider #

keyboard_inset_avoider provides a reliable Android keyboard inset fallback for devices where MediaQuery.viewInsets.bottom is incorrect, plus a simple layout helper for bottom input bars.

What It Solves #

Some Android devices and custom ROMs show the keyboard but do not report a usable bottom inset back to Flutter. On those devices, input bars anchored to the bottom of the screen can be covered by the IME.

This plugin works around that by:

  • reading Flutter's normal MediaQuery.viewInsets.bottom
  • listening to Android window layout changes as a fallback
  • exposing the larger of the two values to Flutter

Install #

dependencies:
  keyboard_inset_avoider:
    path: ../keyboard_inset_avoider

For a published package, replace the path dependency with the pub version.

Usage #

import 'package:flutter/material.dart';
import 'package:keyboard_inset_avoider/keyboard_inset_avoider.dart';

class ChatPage extends StatelessWidget {
  const ChatPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: SafeArea(
        child: KeyboardAvoidingLayout(
          body: ListView(
            padding: const EdgeInsets.all(16),
            children: const [
              Text('Messages...'),
            ],
          ),
          bottomBar: Material(
            elevation: 6,
            borderRadius: BorderRadius.circular(18),
            child: const Padding(
              padding: EdgeInsets.all(16),
              child: TextField(),
            ),
          ),
        ),
      ),
    );
  }
}

Public API #

  • KeyboardInsetAvoider.instance.effectiveInsetOf(context)
  • KeyboardInsetBuilder
  • KeyboardAvoidingLayout

Notes #

  • No host MainActivity changes are required.
  • Android gets the native fallback channel automatically through plugin registration.
  • Non-Android platforms continue to use Flutter's own MediaQuery.viewInsets.bottom.
0
likes
150
points
40
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Reliable keyboard inset fallback and bottom-bar avoidance widgets for Flutter.

Repository (GitHub)
View/report issues

Topics

#keyboard #input #android #layout #flutter-plugin

License

MIT (license)

Dependencies

flutter

More

Packages that depend on keyboard_inset_avoider

Packages that implement keyboard_inset_avoider