1

I was wondering if it is possible to have borders only on specific sides on Flutter TextField. In this particular case, I need only top and left, but would like to know in general if this is possible, thank you.

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
user3808307
  • 2,270
  • 9
  • 45
  • 99

2 Answers2

3

you can wrap the TextField widget with Container and give border:

Container(
 decoration: BoxDecoration(
 color: Colors.white,
 border: Border(
  top: BorderSide(color: Colors.red),
  left: BorderSide(color: Colors.red),
  ),
 ),
 child: TextFormField(
  decoration: InputDecoration(
   labelText: 'Email',
   border: InputBorder.none,
  ),
 ),
),

the result: enter image description here

keepant
  • 196
  • 2
  • 7
1

Yes, sure you can, try this (or check DartPad I made for it : https://dartpad.dev/1a28bdd9203250d3226cc25d512579ec?null_safety=true):

Padding(
        padding: const EdgeInsets.all(8.0),
        child: Container(
          padding: EdgeInsets.all(8.0),
          decoration: BoxDecoration(
            border: Border(
              top: BorderSide(width: 4.0, color: Colors.lightBlue.shade900),
              left: BorderSide(width: 4.0, color: Colors.lightBlue.shade900),
            ),
          ),
          child: TextField(),
        ),
      ),

enter image description here

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210