Control position of validation label

Viewed 1390

When using Form validator the default position of the message label is on the bottom, is there a way to put it on the top of the Text field? enter image description here

1 Answers

You can not change position on validation label in TextFormField

But you can build your own TextFormField by using FormField widget and custumize its children to look like a normal TextFormField this is a working example made with FormField

FormField(
    // initialValue: 0,
    autovalidate: true,
    validator: normalValidator,
    builder: (state) {
    state.validate();
      return Column(
       crossAxisAlignment: CrossAxisAlignment.start,

                  children: <Widget>[
         state.errorText!=null? Text(state.errorText, style: TextStyle(color: Colors.red, fontSize: 12),):Container(),
                            DropdownButton(
                                isExpanded: true,
                                value: state.value,
                                items: _choices,
                                onChanged: (v) {
                                  state.didChange(v);
                                  setState((){});
                                }),

                          ],
                        );
                      }),

You can now customize it to sweet your needs. Find more about FormField here on official doc

Related