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

discontinued
outdated

A new Flutter plugin for check visibility keyboard.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';

import 'package:keyboard_utils/keyboard_utils.dart';
import 'package:keyboard_utils/keyboard_listener.dart';

void main() => runApp(MyApp());

// Sample Bloc
class KeyboardBloc {
  KeyboardUtils  _keyboardUtils = KeyboardUtils();
  StreamController<double> _streamController = StreamController<double>();
  Stream<double> get stream => _streamController.stream;

  KeyboardUtils get keyboardUtils => _keyboardUtils;

  void start() {
    _keyboardUtils.add(listener: KeyboardListener(
        willHideKeyboard: () {
          _streamController.sink.add(_keyboardUtils.keyboardHeight);
        },
        willShowKeyboard: (double keyboardHeight) {
          _streamController.sink.add(keyboardHeight);
        }
    ));
  }

  void dispose() {
    _keyboardUtils.dispose();
    _streamController.close();
  }
}

// App
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  KeyboardBloc _bloc = KeyboardBloc();

  @override
  void initState() {
    super.initState();

    _bloc.start();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Keyboard Utils Sample'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              TextField(),
              TextField(keyboardType: TextInputType.number,),
              TextField(),
              SizedBox(height: 30,),
              StreamBuilder<double>(stream: _bloc.stream,
                builder: (BuildContext context, AsyncSnapshot<double> snapshot) {
                  return Text('is keyboard open: ${_bloc.keyboardUtils.isKeyboardOpen}\n'
                  'Height: ${_bloc.keyboardUtils.keyboardHeight}');
              }),
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _bloc.dispose();

    super.dispose();
  }
}
52
likes
0
points
583
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin for check visibility keyboard.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on keyboard_utils