Giter Site home page Giter Site logo

ffsir / keyboard_utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hello-coder-xu/keyboard_utils

0.0 0.0 0.0 494 KB

A Flutter plugin to check keyboard visibility.

License: MIT License

Ruby 5.64% Objective-C 0.79% Java 16.52% Kotlin 15.41% Dart 50.56% Swift 11.09%

keyboard_utils's Introduction

keyboard_utils

A Flutter plugin to check keyboard visibility and height.

Licence

sample

Install

Follow this guide

How to use

Add the imports:

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

Create the KeyboardUtils:

KeyboardUtils  _keyboardUtils = KeyboardUtils();

Attach the listener to KeyboardUtils:

final int _idKeyboardListener = _keyboardUtils.add(
        listener: KeyboardListener(willHideKeyboard: () {
      // Your code here
    }, willShowKeyboard: (double keyboardHeight) {
      // Your code here
    }));

Remember call dispose:

_keyboardUtils.unsubscribeListener(subscribingId: _idKeyboardListener);
    if (_keyboardUtils.canCallDispose()) {
      _keyboardUtils.dispose();
    }

Instead, you can also use KeyboardAware Widget:

 import 'package:keyboard_utils/widgets.dart';
 
 ....
 
 Widget buildSampleUsingKeyboardAwareWidget() {
    return Center(
      child: Column(
        children: <Widget>[
          TextField(),
          TextField(
            keyboardType: TextInputType.number,
          ),
          TextField(),
          SizedBox(
            height: 30,
          ),
          KeyboardAware(
            builder: (context, keyboardConfig) {
              return Text('is keyboard open: ${keyboardConfig.isKeyboardOpen}\n'
                  'Height: ${keyboardConfig.keyboardHeight}');
            },
          ),
        ],
      ),
    );
  }
  
  ....

To share KeyboardConfig in your widget tree, use the KeyboardConfigInheritedWidget widget.

Check the sample for more details.

Authors

Isaías Santana
Isaías Santana
Will Filho
Will Filho

keyboard_utils's People

Contributors

isaiassantana avatar wilfilho avatar noordawod avatar zeqinjie avatar marcglasberg avatar badboy-tian avatar drarox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.