How to hide input field in TextFormField?

Good morning!
I am customizing flutter ecommerce mobile app from codecanyon - fluxstore.
In the checkout shipping addres template too much fields and I can’t delete them, because all fields connected with models and others parts of app. I want to set them initial value and then hide. How to hide text field?

Exaple of TextFormField from checkout template:

                TextFormField(
                    initialValue: address.firstName,
                    decoration: InputDecoration(labelText: S.of(context).firstName),
                    validator: (val) {
                      return val.isEmpty ? S.of(context).firstNameIsRequired : null;
                    },
                    onSaved: (String value) {
                      address.firstName = value;
                    }),
                TextFormField(
                    initialValue: "LastNamePlaceholder",
                    validator: (val) {
                      return val.isEmpty ? S.of(context).lastNameIsRequired : null;
                    },
                    decoration: InputDecoration(labelText: S.of(context).lastName),
                    onSaved: (String value) {
                      address.lastName = value;
                    }),
                TextFormField(
                    initialValue: address.phoneNumber,
                    validator: (val) {
                      return val.isEmpty ? S.of(context).phoneIsRequired : null;
                    },
                    keyboardType: TextInputType.number,
                    decoration: InputDecoration(labelText: S.of(context).phoneNumber),
                    onSaved: (String value) {
                      address.phoneNumber = value;
                    }),
1 Like

One way to do this would be to wrap the TextFormField in Visibility widget.

              Visibility(
                visible: false,
                child: TextFormField(
                    initialValue: "LastNamePlaceholder",
                    validator: (val) {
                      return val.isEmpty ? S.of(context).lastNameIsRequired : null;
                    },
                    decoration: InputDecoration(labelText: S.of(context).lastName),
                    onSaved: (String value) {
                      address.lastName = value;
                    }),
                   )

Let us know if it helps. :slight_smile:

1 Like