Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove background color of TextField on Flutter Widget?

I can't remove the shadow and the background of the TextField, here is my code:

TextFormField(
                            decoration: InputDecoration.collapsed(),
                            validator: (input) =>
                                input == "" ? 'The task is empty' : null,
                            onSaved: (input) => task = input,
                          )

this is the result that I want

enter image description here

I always try BoxDecoration but no success because don't is compatible with TextFormField.

like image 818
jsdaniell Avatar asked Mar 10 '19 00:03

jsdaniell


People also ask

How do I change the background color of a TextField in Flutter?

Steps to change TextField background color in FlutterStep 1: Locate the file where you have placed the TextField widget. Step 2: Inside the TextField widget, add the decoration parameter and assign the InputDecoration widget. Step 3: Inside the InputDecoration widget, add the filled parameter and set it to true .

How do you clear the TextField in Flutter?

clear(); As mentioned above there are various properties of TextEditingController(). One of them is clear(), and we will use it to clear the TextField.

How do you make a color transparent in Flutter?

static const Color transparent = Color(0x00000000); Flutter.


2 Answers

You should set filled to true.

TextField(decoration: InputDecoration( fillColor: Colors.red, filled: true)),
like image 200
Sameh Khemira Avatar answered Oct 19 '22 21:10

Sameh Khemira


Wrap your TextFormField inside a Container and change its color property to match your background color (as from your picture I'll assume its white):

     Container(
        color: Colors.white, // or any color that matches your background
        child: TextFormField(
                 decoration: InputDecoration.collapsed(),
                 validator: (input) => input == "" ? 'The task is empty' : null,
                 onSaved: (input) => task = input,
               )
     ),
like image 40
Mazin Ibrahim Avatar answered Oct 19 '22 22:10

Mazin Ibrahim