new_virtual_keyboard 0.1.4 copy "new_virtual_keyboard: ^0.1.4" to clipboard
new_virtual_keyboard: ^0.1.4 copied to clipboard

A simple package for dispaying virtual keyboards on a devices like kiosks and ATMs. The library is written in Dart and has no native code dependancy.


FlutterBlue


FlutterBlue


virtual_keyboard #

Introduction #

A simple package for dispaying virtual keyboards on a devices like kiosks and ATMs. The library is written in Dart and has no native code dependancy.

Virtual keyboard provides a core set of functionality to display onscreen virtual keyboards. Managing the events sould be done on the project level.

Reference #

VirtualKeyboard #

Flutter widget to show virtual keyboards.

// Keyboard Type: Can be Numeric or Alphanumeric.
VirtualKeyboardType type
copied to clipboard
// Callback for Key press event. Called with pressed `Key` object.
Function onKeyPress;
copied to clipboard
// Virtual keyboard height. Default is 300.
double height;
copied to clipboard
// Color for key texts and icons.
Color textColor;
copied to clipboard
// Font size for keyboard keys.
double fontSize;;
copied to clipboard
// Only Caps letters enabled.
bool alwaysCaps;;
copied to clipboard

VirtualKeyboardType #

enum of Available Virtual Keyboard Types.

// Numeric only.
VirtualKeyboardType.Numeric
copied to clipboard
// Alphanumeric: letters`[A-Z]` + numbers`[0-9]` + `@` + `.`.
VirtualKeyboardType.Alphanumeric
copied to clipboard

VirtualKeyboardKey #

Virtual Keyboard key.

// The text of the key. 
String text
copied to clipboard
// The capitalized text of the key. 
String capsText;
copied to clipboard
// Action or String
VirtualKeyboardKeyType keyType;
copied to clipboard
// Action of the key.
VirtualKeyboardKeyAction action;
copied to clipboard

VirtualKeyboardKeyType #

Type for virtual keyboard key.

// Can be an action key - Return, Backspace, etc.
VirtualKeyboardKeyType.Action
copied to clipboard
// Keys that have text values - letters, numbers, comma ...
VirtualKeyboardKeyType.String
copied to clipboard

VirtualKeyboardKeyAction #

/// Virtual keyboard actions.
enum VirtualKeyboardKeyAction { Backspace, Return, Shift, Space }
copied to clipboard

Usage #

Show Alphanumeric keyboard with default view

// Wrap the keyboard with Container to set background color.
Container(
            // Keyboard is transparent
            color: Colors.deepPurple,
            child: VirtualKeyboard(
                // Default height is 300
                height: 350,
                // Default is black
                textColor: Colors.white,
                // Default 14
                fontSize: 20,
                // [A-Z, 0-9]
                type: VirtualKeyboardType.Alphanumeric,
                // Callback for key press event
                onKeyPress: _onKeyPress),
          )
copied to clipboard

Show Numeric keyboard with default view

Container(
            // Keyboard is transparent
            color: Colors.red,
            child: VirtualKeyboard(
                // [0-9] + .
                type: VirtualKeyboardType.Numeric,
                // Callback for key press event
                onKeyPress: (key) => print(key.text)),
          )
copied to clipboard

Show Alphanumeric keyboard with customized keys

 Container(
            color: Colors.deepPurple,
            child: VirtualKeyboard(
                height: keyboardHeight,
                textColor: Colors.white,
                fontSize: 20,
                builder: _builder,
                type: VirtualKeyboardType.Numeric,
                onKeyPress: _onKeyPress),
          )

  /// Builder for keyboard keys.
  Widget _builder(BuildContext context, VirtualKeyboardKey key) {
    Widget keyWidget;

    switch (key.keyType) {
      case VirtualKeyboardKeyType.String:
        // Draw String key.
        keyWidget = _keyboardDefaultKey(key);
        break;
      case VirtualKeyboardKeyType.Action:
        // Draw action key.
        keyWidget = _keyboardDefaultActionKey(key);
        break;
    }

    return keyWidget;
  }          
copied to clipboard

onKeyPressed event basic ussage example

// Just local variable. Use Text widget or similar to show in UI.
String text;

  /// Fired when the virtual keyboard key is pressed.
_onKeyPress(VirtualKeyboardKey key) {
if (key.keyType == VirtualKeyboardKeyType.String) {
    text = text + (shiftEnabled ? key.capsText : key.text);
} else if (key.keyType == VirtualKeyboardKeyType.Action) {
    switch (key.action) {
    case VirtualKeyboardKeyAction.Backspace:
        if (text.length == 0) return;
        text = text.substring(0, text.length - 1);
        break;
    case VirtualKeyboardKeyAction.Return:
        text = text + '\n';
        break;
    case VirtualKeyboardKeyAction.Space:
        text = text + key.text;
        break;
    case VirtualKeyboardKeyAction.Shift:
        shiftEnabled = !shiftEnabled;
        break;
    default:
    }
}
// Update the screen
setState(() {});
}
copied to clipboard
8
likes
120
points
801
downloads

Publisher

verified publishercodelyticaleg.com

Weekly Downloads

2024.09.16 - 2025.03.31

A simple package for dispaying virtual keyboards on a devices like kiosks and ATMs. The library is written in Dart and has no native code dependancy.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on new_virtual_keyboard