virtual_keypad library
A Flutter package for creating customizable virtual on-screen keyboards.
This package provides a complete solution for custom keyboard input, including text fields that integrate seamlessly with virtual keyboards, theming support, and multiple keyboard layouts that adapt to input type.
Getting Started
Standalone Mode (simplest)
Use VirtualKeypad(standalone: true) with any standard Flutter TextField:
Column(
children: [
TextField(controller: myController),
VirtualKeypad(standalone: true),
],
)
Scope Mode (full control)
Wrap your widget tree with VirtualKeypadScope, then use VirtualKeypadTextField and VirtualKeypad together:
VirtualKeypadScope(
child: Column(
children: [
VirtualKeypadTextField(controller: controller),
VirtualKeypad(),
],
),
)
Input-Aware Layouts
The keyboard automatically adapts based on the text field's input type. In standalone mode, it reads the TextInputType from the focused field. In scope mode, set KeyboardType on VirtualKeypadTextField.
Key Components
- VirtualKeypad - Customizable on-screen keyboard widget
- VirtualKeypadScope - Manages keyboard-to-textfield connections (scope mode)
- VirtualKeypadStandaloneScope - Restricts standalone keyboard to a widget subtree
- VirtualKeypadTextField - Text field optimized for virtual keyboard input (scope mode)
- VirtualKeypadController - Controller with text manipulation methods
- VirtualKeypadTheme - Theming for keyboard appearance
- KeyboardType - Input types that determine keyboard layout
- StandaloneInputControl - Text input interceptor for standalone mode
Classes
- KeyboardLanguage
- Defines all keyboard layouts for a specific language.
- KeyboardLayoutProvider
- Manages keyboard languages and provides access to layouts.
- KeyboardLayoutSet
- A complete set of keyboard layouts for a specific input type.
- StandaloneInputControl
- A TextInputControl that intercepts Flutter's text input system, allowing VirtualKeypad to work with any standard TextField or TextFormField without requiring VirtualKeypadScope.
- VirtualKey
- Represents a single key on the virtual keyboard.
- VirtualKeypad
- A customizable virtual on-screen keyboard widget.
- VirtualKeypadController
- A controller for VirtualKeypadTextField that provides text manipulation methods.
- VirtualKeypadScope
- Manages the connection between VirtualKeypadTextField widgets and VirtualKeypad.
- VirtualKeypadScopeState
- State for VirtualKeypadScope.
- VirtualKeypadStandaloneScope
- Scopes a VirtualKeypad in standalone mode to only respond to text fields within its subtree.
- VirtualKeypadStandaloneScopeState
- State for VirtualKeypadStandaloneScope.
- VirtualKeypadTextField
- A text field that integrates with VirtualKeypad through VirtualKeypadScope.
- VirtualKeypadTheme
- Theme configuration for VirtualKeypad appearance.
- VkpColors
- Default color constants for VirtualKeypadTheme.
Enums
- KeyAction
- Actions that can be performed by special keys on the keyboard.
- KeyboardInputType
- Simplified input type categories for layout selection.
- KeyboardType
- Keyboard input types that determine the layout shown.
- KeyType
- The type of a virtual keyboard key.
- LayoutStage
- Current layout stage for keyboards with multiple pages.
Properties
- bengaliLanguage → KeyboardLanguage
-
Bengali (বাংলা) keyboard language.
final
- decimalLayout → KeyboardLayout
-
Decimal number layout (0-9 with decimal point, no extra characters).
final
- emailLayoutPrimary → KeyboardLayout
-
Email keyboard - primary layout with @ readily accessible.
Similar to standard QWERTY but with @ and . on the bottom row.
final
- emailLayoutSecondary → KeyboardLayout
-
Email keyboard - secondary layout (numbers & symbols).
final
- emailLayoutTertiary → KeyboardLayout
-
Email keyboard - tertiary layout (more symbols).
final
- englishLanguage → KeyboardLanguage
-
English (QWERTY) keyboard language.
final
- frenchLanguage → KeyboardLanguage
-
French (AZERTY) keyboard language.
final
- numberLayout → KeyboardLayout
-
Standard number pad layout (0-9 with decimal).
final
- phoneLayout → KeyboardLayout
-
Phone dialer layout with standard phone pad characters.
final
- phoneSimpleLayout → KeyboardLayout
-
Simple phone layout (just numbers and basic symbols).
final
- signedNumberLayout → KeyboardLayout
-
Signed number pad layout (includes - for negative numbers).
final
- textLayoutPrimary → KeyboardLayout
-
Standard QWERTY text layout - primary (letters).
final
- textLayoutSecondary → KeyboardLayout
-
Text layout - secondary (numbers & common symbols).
final
- textLayoutTertiary → KeyboardLayout
-
Text layout - tertiary (more symbols).
final
- urlLayoutPrimary → KeyboardLayout
-
URL keyboard - primary layout with common URL characters accessible.
Has .com, /, : readily available on the bottom row.
final
- urlLayoutSecondary → KeyboardLayout
-
URL keyboard - secondary layout (numbers & symbols).
final
- urlLayoutTertiary → KeyboardLayout
-
URL keyboard - tertiary layout (more symbols).
final
Functions
-
initializeKeyboardLayouts(
) → void - Initialize the provider with default languages.
Typedefs
-
KeyboardLayout
= List<
KeyRow> - A complete keyboard layout consisting of multiple rows.
-
KeyRow
= List<
VirtualKey> - A row of keys in a keyboard layout.