Want to add textfield background color on focus in Flutter? It looks like it’s caused by the splash effect on the textfield. I couldn’t find a way to disable it for that specific widget but you can make it transparent by wrapping your TextField in a Theme widget and setting the splashColor to transparent:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | Theme( data: Theme.of(context).copyWith(splashColor: Colors.transparent), child: TextField( autofocus: false, style: TextStyle(fontSize: 22.0, color: Color(0xFFbdc6cf)), decoration: InputDecoration( filled: true, fillColor: Colors.white, hintText: 'Username', contentPadding: const EdgeInsets.only(left: 14.0, bottom: 8.0, top: 8.0), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.circular(25.7), ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.circular(25.7), ), ), ), ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.