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

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

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  double _keyboardHeight = 0;
  final WaitKeyboardHeight _waitKeyboardHeight = WaitKeyboardHeight();

  @override
  void initState() {
    super.initState();
    _waitKeyboardHeight.onKeyboardHeightChanged((double height) {
      setState(() {
        _keyboardHeight = height;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        title: Text('Keyboard Height'),
      ),
      body: Center(
        child: Stack(
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'Keyboard height: $_keyboardHeight',
                ),
                SizedBox(height: 16),
                ElevatedButton(
                  child: Text('Get Keyboard Height'),
                  onPressed: () => {},
                ),
              ],
            ),
            Positioned(
              bottom: _keyboardHeight,
              left: 0,
              right: 0,
              child: TextField(
                decoration: InputDecoration(
                  filled: true,
                  fillColor: Colors.orange,
                  hintText: 'Type here to open keyboard',
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
4
likes
150
points
70
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on wait_keyboard_height

Packages that implement wait_keyboard_height