virtual_keypad v1.1.1
pub.dev GitHub

Theming

Two presets to start from, and every property on them can be replaced.

Install#

flutter pub add virtual_keypad
import 'package:virtual_keypad/virtual_keypad.dart';

The presets#

VirtualKeypad(theme: VirtualKeypadTheme.light)
VirtualKeypad(theme: VirtualKeypadTheme.dark)

Changing part of one#

copyWith is almost always what you want. Building a theme from scratch means restating every colour, and a value you forget is a default rather than an error.

VirtualKeypad(
  theme: VirtualKeypadTheme.dark.copyWith(
    keyBorderRadius: 12,
    keyTextSize: 24,
  ),
)

A theme of your own#

VirtualKeypad(
  theme: VirtualKeypadTheme(
    backgroundColor: Colors.grey[900]!,
    keyColor: Colors.grey[800]!,
    actionKeyColor: Colors.grey[700]!,
    keyTextColor: Colors.white,
    keyBorderRadius: 12,
  ),
)

Every property#

PropertyTypeDefaultWhat it does
backgroundColorColor#D1D3D9Keyboard background
keyColorColor#FFFFFFCharacter key background
actionKeyColorColor#ADB3BCAction key background
keyTextColorColor#1C1C1EText and icon colour
keyTextSizedouble22.0Font size
keyBorderRadiusdouble6.0Corner radius
keyShadowbooltrueKey shadows
splashColorColor?nullTap ripple colour
horizontalGapdoubleSpace between keys in a row
verticalGapdoubleSpace between rows
focusBorderColorColor?keyTextColorD-pad highlight border
focusBorderWidthdouble3.0D-pad highlight border width
focusColorColor?nullD-pad highlight fill

Following the app theme#

The keyboard does not read Theme.of(context) on its own, because a keyboard often wants to differ from the surrounding app. Wire it up yourself when you do want it to match.

final dark = Theme.of(context).brightness == Brightness.dark;

VirtualKeypad(
  theme: dark ? VirtualKeypadTheme.dark : VirtualKeypadTheme.light,
)

Sizing for the screen#

Colour is the easy part. The change that matters most is key size, and it depends entirely on how far away the user is.

ScreenReasonable starting point
PhoneDefaults, held close and tapped with a thumb
Tablet or desktopkeyTextSize: 24, a little more gap
Kiosk or POSheight: 340, keyTextSize: 26, gaps at 8
TelevisionDark theme, a strong focus highlight, large text