build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Build the widget.

Implementation

@override
Widget build(final BuildContext context) => CallbackShortcuts(
      bindings: {
        moveDownShortcut: () {
          final i = value - modifier;
          if (i >= (min ?? i)) {
            onChanged(i);
          }
        },
        moveUpShortcut: () {
          final i = value + modifier;
          if (i <= (max ?? i)) {
            onChanged(i);
          }
        },
        moveToStartShortcut: () => onChanged(min ?? value),
        moveToEndShortcut: () => onChanged(max ?? value),
      },
      child: ListTile(
        autofocus: autofocus,
        title: Text(title),
        subtitle: Text(subtitle ?? value.toString()),
        onTap: () => context.pushWidgetBuilder(
          (final context) => GetText(
            onDone: (final value) {
              Navigator.pop(context);
              onChanged(int.parse(value));
            },
            labelText: labelText,
            text: value.toString(),
            title: title,
            validator: (final value) {
              if (value == null || value.isEmpty) {
                return 'You must provide a value';
              }
              final i = int.tryParse(value);
              if (i == null) {
                return 'Invalid number';
              }
              if (i < (min ?? i)) {
                return 'You must use a number no less than $min';
              }
              if (i > (max ?? i)) {
                return 'You must use a number no more than $max';
              }
              return null;
            },
          ),
        ),
        onLongPress: onLongPress,
      ),
    );