build method

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

Build the widget.

Implementation

@override
Widget build(final BuildContext context) {
  final text = value.toStringAsFixed(decimalPlaces);
  return 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 ?? text),
      onTap: () => context.pushWidgetBuilder(
        (final context) => GetText(
          onDone: (final value) {
            Navigator.pop(context);
            onChanged(double.parse(value));
          },
          actions: actions,
          text: text,
          title: title,
          validator: (final value) {
            final d = value == null ? null : double.tryParse(value);
            if (value == null || value.isEmpty) {
              return 'You must enter a value';
            } else if (d == null) {
              return 'Invalid number';
            } else if (d < (min ?? d)) {
              return 'Value must be at least $min';
            } else if (d > (max ?? d)) {
              return 'Value must be no more than $max';
            }
            return null;
          },
        ),
      ),
      onLongPress: onLongPress,
    ),
  );
}