DEV Community 👩‍💻👨‍💻

Discussion on: Star Rating with Flutter Reactive Forms

inmer profile image

Hi Joan, thanks for reply.

I should clarify my question my bad sorry, RDateTimePicker is just a visual customization of date_time_picker from on, here is my implementation:

class RDateTimePicker extends StatelessWidget {
  final TextEditingController controller;
  final String labelText;
  final Function(String) validator;
  final Function(String) onChanged;

  const RDateTimePicker({
    Key key,
  }) : super(key: key);

  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(5),
      child: DateTimePicker(
          onChanged: onChanged,
          controller: controller,
              TextStyle(color:, decoration: TextDecoration.none),
          decoration: InputDecoration(
            labelText: labelText,
            enabledBorder: UnderlineInputBorder(
                borderSide: BorderSide(color:,
            focusedBorder: UnderlineInputBorder(
                borderSide: BorderSide(color:,
            labelStyle: TextStyle(color:
          validator: validator),
Enter fullscreen mode Exit fullscreen mode

And with "normal" form, I am able to show errors using validator property, and a controller. Can't I use its implementation to show the error or anyway I have to create an InputDecorator. By the way I would like an example for those InputDecorator, because I have created a completely custom component in which I would need what you say. And thanks for such a great library.

Thread Thread
joanpablo profile image
Joan Pablo Author • Edited on

There you have an InputDecoration. You should avoid using validator, and instead use the errorText of the decoration. You can search for the implementation of the ReactiveTextField to see how it is using this approach.

builder: (ReactiveFormFieldState field) {
   final state = field as _ReactiveTextFieldState;
   final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration())

   return DateTimePicker(
      decoration: effectiveDecoration.copyWith(errorText: state.errorText),

Enter fullscreen mode Exit fullscreen mode

In the above code, I'm not using your RDateTimePicker just to simplify things, but it also applies with your wrapper widget.

Thread Thread
inmer profile image

Thank you, Joan finally I was able to make it work for both cases, greatly appreciate your help.