311

This is what I'm trying to make:

enter image description here

In the Flutter docs for Text Fields (https://flutter.io/text-input/) it says you can remove the underline by passing null to the decoration. However, that also gets rid of the hint text.

I do not want any underline whether the text field is focused or not.

UPDATE: updated accepted answer to reflect changes in Flutter SDK as of April 2020.

juan park
  • 3,224
  • 2
  • 10
  • 13

13 Answers13

467

Do it like this:

TextField(
  decoration: new InputDecoration.collapsed(
    hintText: 'Username'
  ),
),

or if you need other stuff like icon, set the border with InputBorder.none

InputDecoration(
    border: InputBorder.none,
    hintText: 'Username',
  ),
),
User
  • 31,811
  • 40
  • 131
  • 232
Made Baruna
  • 6,080
  • 3
  • 16
  • 11
318

New Flutter SDK since after integration of web and desktop support you need to specify individually like this:

TextFormField(
  cursorColor: Colors.black,
  keyboardType: inputType,
  decoration: InputDecoration(
    border: InputBorder.none,
    focusedBorder: InputBorder.none,
    enabledBorder: InputBorder.none,
    errorBorder: InputBorder.none,
    disabledBorder: InputBorder.none,
    contentPadding:
      EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
    hintText: "Hint here"),
)
Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76
sourav pandit
  • 8,647
  • 2
  • 19
  • 17
  • How can I give a radius after applying this solution? – Jay Tillu Aug 25 '21 at 10:23
  • 1
    @JayTillu This video demonstrates it quite well: https://youtu.be/3zddqfn0dfc – Christian Aug 30 '21 at 17:56
  • 1
    Or u can just simly use one and only `border: InputBorder.none` to turn off all kinds of borders (i.e. `focusedBorder`, `enabledBorder`, `errorBorder`, `disabledBorder`). – Son Nguyen Sep 27 '21 at 10:06
  • using this will give you 100 % border less even for TextFormField. and you can style you component or make stateless widget component its up-to you – sourav pandit Oct 05 '21 at 04:06
57

Here is a supplemental answer that shows some fuller code:

enter image description here

  Container(
    decoration: BoxDecoration(
      color: Colors.tealAccent,
      borderRadius:  BorderRadius.circular(32),
    ),
    child: TextField(
      decoration: InputDecoration(
        hintStyle: TextStyle(fontSize: 17),
        hintText: 'Search your trips',
        suffixIcon: Icon(Icons.search),
        border: InputBorder.none,
        contentPadding: EdgeInsets.all(20),
      ),
    ),
  ),

Notes:

  • The dark background (code not shown) is Colors.teal.
  • InputDecoration also has a filled and fillColor property, but I couldn't get them to have a corner radius, so I used a container instead.
Yushin
  • 1,684
  • 3
  • 20
  • 36
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
32

I found no other answer gives a border radius, you can simply do it like this, no nested Container

  TextField(
    decoration: InputDecoration(
      border: OutlineInputBorder(
        borderSide: BorderSide.none,
        borderRadius: BorderRadius.circular(20),
      ),
    ),
  );
E. Sun
  • 1,093
  • 9
  • 15
22

change the focused border to none

TextField(
      decoration: new InputDecoration(
          border: InputBorder.none,
          focusedBorder: InputBorder.none,
          contentPadding: EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
          hintText: 'Subject'
      ),
    ),
Sarthak Singhal
  • 1,175
  • 12
  • 16
5

To make a Borderless TextFormField i found below solution:

It is without using container.

TextFormField(
      decoration: InputDecoration(
          border: OutlineInputBorder(
                         borderRadius: BorderRadius.circular(15.0),
                         borderSide: BorderSide.none,
                            ),

           labelText: "Student email/id",
           floatingLabelStyle: const TextStyle(
                                    height: 4,
                                    color: Color.fromARGB(255, 160, 26, 179)),
                                
           filled: true,
           fillColor: Colors.grey[200],
           prefixIcon: const Icon(Icons.person),
                ),
           ),

Sample Normally: Normally Looks like this

While having input error: On error

While user input: while entering data

4

To remove TextField underline border in Flutter, you can simply set border to InputBorder.none.

TextField(
  decoration: InputDecoration(
    hintText: 'Hint Text',
    border: InputBorder.none,
  ),
)
Saad
  • 539
  • 2
  • 19
Fakhriddin Abdullaev
  • 4,169
  • 2
  • 35
  • 37
3

TextField(style: TextStyle(color: Colors.black45,fontSize: 18,decorationThickness: 0.0)).
It's showing without underline with decorationThickness:0.0.

gurkan
  • 884
  • 4
  • 16
  • 25
U Anil
  • 49
  • 4
1
            Container(
         height: 50,
          // margin: EdgeInsets.only(top: 20),
          decoration: BoxDecoration(
              color: Colors.tealAccent,
              borderRadius: BorderRadius.circular(32)),
          child: TextFormField(
            cursorColor: Colors.black,
            // keyboardType: TextInputType.,
            decoration: InputDecoration(
              hintStyle: TextStyle(fontSize: 17),
              hintText: 'Search your trips',
              suffixIcon: Icon(Icons.search),
              border: InputBorder.none,
              contentPadding: EdgeInsets.all(18),
            ),
          ),
        ),
1

Default

enter image description here

 Container(
      padding: const EdgeInsets.all(20),
      child: const TextField(
        decoration: InputDecoration(
            border: UnderlineInputBorder(), hintText: "Search Your tips"),
      ),
    ),

Outline Border

enter image description here

 Container(
      padding: const EdgeInsets.all(20),
      child: TextField(
        decoration: InputDecoration(
          border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(40),
          ),
          hintText: "Search Your tips",
        ),
      ),
    ),

No Border

enter image description here

 Container(
      padding: const EdgeInsets.all(20),
      child: const TextField(
        decoration: InputDecoration(
            border: InputBorder.none, hintText: "Search Your tips"),
      ),
    ),
krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88
1

Try the following code:

TextFormField(
  decoration: InputDecoration(
    border: OutlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(30.0)),
    hintText: "Search your trips",
    hintStyle: const TextStyle(color: Colors.white, fontWeight: FontWeight.w300),
    filled: true,
    fillColor: Colors.cyan[200],
    suffixIcon: IconButton(
      onPressed: () {},
      icon: const Icon(Icons.search, color: Colors.white),
    ),
  ),
),
My Car
  • 4,198
  • 5
  • 17
  • 50
0
decoration: InputDecoration(
 border:OutLineInputBorder(
 borderSide:BorderSide.none
 bordeRadius: BordeRadius.circular(20.0)
 )
)
jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
S.R Keshav
  • 1,965
  • 1
  • 11
  • 14
  • What's the difference between this answer and [@E. Sun's answer](https://stackoverflow.com/a/61442959/3025856) from a month ago? – Jeremy Caney Jul 05 '20 at 21:13
  • You want something new? – S.R Keshav Jul 06 '20 at 00:54
  • 6
    If an answer has already been provided, there's no need to submit it again. Doing so only adds noise for future readers, as they need to sort through multiple similar answers. In the future, once you've gained a bit more reputation, you'll be able to upvote existing answers; that's the preferred way of validating an approach and affirming that the solution works. – Jeremy Caney Jul 06 '20 at 00:57
  • 5
    I should note that, on occasion, contributors will _still_ post a similar advice if they have a different way of explaining it, or want to add considerable more detail. That's totally fine. The issue here is that you seem to be providing the _same_ answer, but with _less_ detail, so it doesn't contribute much to the thread. – Jeremy Caney Jul 06 '20 at 00:59
0

To remove underline border: InputBorder.none,

For hint use hintText: 'Hint Text'

   TextFormField(
      InputDecoration(
        border: InputBorder.none,
        hintText: 'Hint Text',
      ),
    ),
Anand
  • 4,355
  • 2
  • 35
  • 45