defaultTriggerBuilder static method

Widget defaultTriggerBuilder(
  1. FormeTimeFieldState state, {
  2. InputDecoration? decoration,
  3. String formatter(
    1. TimeOfDay? time
    )?,
  4. bool clearButton = true,
})

Implementation

static Widget defaultTriggerBuilder(
  FormeTimeFieldState state, {
  InputDecoration? decoration,
  String Function(TimeOfDay? time)? formatter,
  bool clearButton = true,
}) {
  return InkWell(
    focusNode: state.focusNode,
    onTap: state.showPicker,
    child: InputDecorator(
      isFocused: state.hasFocus,
      isEmpty: state.value == null,
      decoration: (decoration ?? const InputDecoration()).copyWith(
        errorText: state.errorText,
        suffixIconConstraints:
            !clearButton ? null : const BoxConstraints.tightFor(),
        suffixIcon: !clearButton
            ? null
            : FormeFieldStatusListener<TimeOfDay?>(
                builder: (context, status, child) {
                  if (status != null && status.value != null) {
                    return IconButton(
                      onPressed: () {
                        FormeField.of(context)!.value = null;
                      },
                      icon: const Icon(Icons.clear),
                    );
                  }
                  return const SizedBox.shrink();
                },
              ),
      ),
      child: Text(formatter?.call(state.value) ?? '${state.value ?? ''}'),
    ),
  );
}