keyboard_actions 2.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 96

Keyboard Actions #

pub package

Add features to the Android / iOS keyboard in a simple way.

Because the keyboard that Android / iOS offers us specifically when we are in numeric mode, does not bring the button to hide the keyboard. This causes a lot of inconvenience for users, so this package allows adding functionality to the existing keyboard.

Features #

  • Done button for the keyboard ( You can customize the button).
  • Move up/down between your Textfields.
  • Keyboard Bar customization.
  • Custom footer widget below keyboard bar
  • You can use it for Android, iOS or both platforms.
  • Compatible with Dialog.

Example of the custom footer:

Screen Shot 2019-05-22 at 5 46 50 PM

For more fun, use that widget as a custom keyboard with your custom input:

Screen Shot 2019-05-22 at 5 46 54 PM

Getting started #

You should ensure that you add the dependency in your flutter project.

dependencies:
  keyboard_actions: "^2.1.1"

You should then run flutter packages upgrade or update your packages in IntelliJ.

Example Project #

There is an example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Usage #

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


//Full screen 
class ScaffoldTest extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      appBar: AppBar(
        title: Text("Keyboard Actions Sample"),
      ),
      body: FormKeyboardActions(
        child: Content(),
      ),
    );
  }
}

//Dialog

/// Displays our [FormKeyboardActions] nested in a [AlertDialog].
class DialogTest extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: true,
        appBar: AppBar(
          title: Text("Keyboard Actions Sample"),
        ),
        body: Builder(builder: (context) {
          return Center(
            child: FlatButton(
              color: Colors.blue,
              child: Text('Launch dialog'),
              onPressed: () => _launchInDialog(context),
            ),
          );
        }));
  }

  _launchInDialog(BuildContext context) {
    showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: Text('Dialog test'),
          content: FormKeyboardActions(autoScroll: true, child: Content()),
          actions: [
            FlatButton(
              child: Text('Ok'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
}


 class Content extends StatefulWidget {
  @override
  _ContentState createState() => _ContentState();
}

class _ContentState extends State<Content> {
  final FocusNode _nodeText1 = FocusNode();
  final FocusNode _nodeText2 = FocusNode();
  final FocusNode _nodeText3 = FocusNode();
  final FocusNode _nodeText4 = FocusNode();
  final FocusNode _nodeText5 = FocusNode();

  /// Creates the [KeyboardActionsConfig] to hook up the fields
  /// and their focus nodes to our [FormKeyboardActions].
  KeyboardActionsConfig _buildConfig(BuildContext context) {
    return KeyboardActionsConfig(
      keyboardActionsPlatform: KeyboardActionsPlatform.ALL,
      keyboardBarColor: Colors.grey[200],
      nextFocus: true,
      actions: [
        KeyboardAction(
          focusNode: _nodeText1,
        ),
        KeyboardAction(
          focusNode: _nodeText2,
          closeWidget: Padding(
            padding: EdgeInsets.all(8.0),
            child: Icon(Icons.close),
          ),
        ),
        KeyboardAction(
          focusNode: _nodeText3,
          onTapAction: () {
            showDialog(
                context: context,
                builder: (context) {
                  return AlertDialog(
                    content: Text("Custom Action"),
                    actions: <Widget>[
                      FlatButton(
                        child: Text("OK"),
                        onPressed: () => Navigator.of(context).pop(),
                      )
                    ],
                  );
                });
          },
        ),
        KeyboardAction(
          focusNode: _nodeText4,
          displayCloseWidget: false,
        ),
        KeyboardAction(
          focusNode: _nodeText5,
          closeWidget: Padding(
            padding: EdgeInsets.all(5.0),
            child: Text("CLOSE"),
          ),
        ),
      ],
    );
  }

  @override
  void initState() {
    // Configure keyboard actions
    FormKeyboardActions.setKeyboardActions(context, _buildConfig(context));
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Padding(
        padding: const EdgeInsets.all(15.0),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              TextField(
                keyboardType: TextInputType.number,
                focusNode: _nodeText1,
                decoration: InputDecoration(
                  hintText: "Input Number",
                ),
              ),
              TextField(
                keyboardType: TextInputType.text,
                focusNode: _nodeText2,
                decoration: InputDecoration(
                  hintText: "Input Text with Custom Close Widget",
                ),
              ),
              TextField(
                keyboardType: TextInputType.number,
                focusNode: _nodeText3,
                decoration: InputDecoration(
                  hintText: "Input Number with Custom Action",
                ),
              ),
              TextField(
                keyboardType: TextInputType.text,
                focusNode: _nodeText4,
                decoration: InputDecoration(
                  hintText: "Input Text without Close Widget",
                ),
              ),
              TextField(
                keyboardType: TextInputType.number,
                focusNode: _nodeText5,
                decoration: InputDecoration(
                  hintText: "Input Number with Custom Close Widget",
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

You can follow me on twitter @diegoveloper

[2.1.0 - 2.1.1]

  • Custom footer widget below keyboard bar
  • Now you can add your custom keyboard!!
  • Thanks @jayjwarrick again for the contribution

[2.0.1]

  • Disable next & previous buttons when there is none

[2.0.0] ** Breaking change **

  • Now KeyboardActions works on Dialogs
  • Add KeyboardActionsConfig to make parameters easily swappable
  • Add FormKeyboardActions.setKeyboardActions and FormKeyboardActions to allow changing the config from anywhere in the child widget tree. (Check the sample)
  • Thanks @jayjwarrick for the contribution

[1.0.4]

  • Added enabled attribute for KeyboardAction to skip the prev/next when the TextField is disabled

[1.0.3]

  • Fixed android issue when return from background

[1.0.0 - 1.0.2]

  • First release.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  keyboard_actions: ^2.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:keyboard_actions/keyboard_actions.dart';
  
Version Uploaded Documentation Archive
2.1.1 May 30, 2019 Go to the documentation of keyboard_actions 2.1.1 Download keyboard_actions 2.1.1 archive
2.1.0 May 28, 2019 Go to the documentation of keyboard_actions 2.1.0 Download keyboard_actions 2.1.0 archive
2.0.1 May 11, 2019 Go to the documentation of keyboard_actions 2.0.1 Download keyboard_actions 2.0.1 archive
2.0.0 May 9, 2019 Go to the documentation of keyboard_actions 2.0.0 Download keyboard_actions 2.0.0 archive
1.0.4 Apr 13, 2019 Go to the documentation of keyboard_actions 1.0.4 Download keyboard_actions 1.0.4 archive
1.0.3 Dec 17, 2018 Go to the documentation of keyboard_actions 1.0.3 Download keyboard_actions 1.0.3 archive
1.0.2 Dec 6, 2018 Go to the documentation of keyboard_actions 1.0.2 Download keyboard_actions 1.0.2 archive
1.0.1 Dec 6, 2018 Go to the documentation of keyboard_actions 1.0.1 Download keyboard_actions 1.0.1 archive
1.0.0 Dec 5, 2018 Go to the documentation of keyboard_actions 1.0.0 Download keyboard_actions 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on Jun 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/external/bottom_area_avoider.dart. (-0.50 points)

Analysis of lib/external/bottom_area_avoider.dart reported 1 hint:

line 165 col 10: The member 'describeSemanticsConfiguration' can only be used within instance members of subclasses of 'package:flutter/src/rendering/object.dart'.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0-dev.0.5.flutter-a1668566e5 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8