John Reaper
John Reaper

Reputation: 305

How to disable textformfield border when click?

When click textformfield:

enter image description here

Not click textformfield:

enter image description here

How to disable textformfield border when clicked. I want when the textformfield is clicked the border doesn't change to blue color. Does anyone know how to make it?

This is my code:

TextFormField(
                                              controller: searchPatient,
                                              
                                              decoration: InputDecoration(
                                                suffixIcon: InkWell(
                                                  onTap: () => {
                                                    setState(() {
                                                      _getAppointmentList(
                                                          searchPatient.text,
                                                          selectedStatus,
                                                          0);
                                                    })
                                                  },
                                                  child: Container(
                                                    height: 25,
                                                    color: Color.fromRGBO(
                                                        14, 113, 176, 1),
                                                    child: AspectRatio(
                                                      aspectRatio: 2 / 1,
                                                      child: Center(
                                                          child: Icon(
                                                        Icons.search,
                                                        color: Colors.white,
                                                      )),
                                                    ),
                                                  ),
                                                ),
                                                hintText:
                                                    'Search Patient Namore, MRN  ID.',
                                                hintStyle: TextStyle(
                                                  color: Colors.grey,
                                                  fontSize: 16,
                                                ),
                                                /* contentPadding:
                                                    EdgeInsets.symmetric(
                                                        vertical: 20,
                                                        horizontal: 15),*/
                                                contentPadding:
                                                    EdgeInsets.symmetric(
                                                        horizontal: 15),
                                                border: OutlineInputBorder(
                                                  borderSide: BorderSide(
                                                      width: 1,
                                                      color: Colors.black),
                                                ),
                                              ),
                                            ),

Upvotes: 0

Views: 167

Answers (1)

Pathik Patel
Pathik Patel

Reputation: 1510

Set the focusedBorder same as enabledBorder (enabledBorder is applied as default view)

The focusedBorder will be applied on the tap event (when the text field is focused)

TextFormField(
  decoration: InputDecoration(
    enabledBorder: const OutlineInputBorder(borderSide: BorderSide()),
    focusedBorder: const OutlineInputBorder(borderSide: BorderSide()),
  ),
)

Upvotes: 3

Related Questions