In this tutorial, we’ll learn how to properly change Flutter textfield focused outline border color by using a practical Flutter code example.
Introduction: Flutter Textfield Focused Outline Border Color
Focused border of textfield is shown when the textfield is focused/tapped. When we use outline border then it covers all the border sides of the textfield.
Don’t worry, I will now implement it using proper example so you can have a better idea of what outline border is and how can we change Flutter textfield focused outline border color.
Default Focused Outline Border Color
- For that we have to implement a simple Flutter textfield widget.
- After that, we’ve to use the decoration constructor of the Flutter textfield, then pass it input decoration class.
- Finally, we’ve to pass the outline input border class to its focused border constructor. See the below code:
TextField( decoration: InputDecoration( focusedBorder: OutlineInputBorder() ), )

Change Flutter Textfield Focused Outline Border Color
For that we have to use the same process mentioned above and after that we have to use the border side constructor of the outline input border class and pass it the border side widget. Then by using the color constructor of border side class, we can change the color of the outline border of focused Flutter textfield. See the below code:
focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.green))

Custom Flutter Textfield Focused Outline Border Color Source Code
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Homepage(), ); } } class Homepage extends StatelessWidget { @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 40), child: TextField( decoration: InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.green))), ))))); } }
Conclusion
To conclude this tutorial, now you’ve a detailed and in-depth practical knowledge of how to change Flutter textfield focused outline border color. I’d love to have your feedback on this post.
I’d also love to see you visit my other tutorials on Flutter app development and Python programming as well. Thank you for reading this post.