How To Change Flutter Textfield Outline Border Color – Easy Flutter Guide

flutter textfield outline border color

In this tutorial, we’ll learn how to properly use Flutter textfield outline border color by using a practical Flutter code example.

Introduction: Flutter Textfield Outline Border Color?

Flutter textfield outline border color is as the name suggests, it is the color of the Flutter textfield border, 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 outline border color.

Default Outline Border Color

Let’s see the default Flutter textfield outline border color. For that we have to use the decoration constructor of the Flutter textfield, then pass it input decoration class and by using the enabled and focused border constructors, we can pass the outline input border class. See the below code:

TextField(
           decoration: InputDecoration(
                  enabledBorder: OutlineInputBorder(),
                  focusedBorder: OutlineInputBorder(),
                ),
              )
flutter textfield outline border default color
You can see in the above image the default Flutter textfield outline border color.

Change Flutter Textfield Outline Border Color

Now let’s implement the customization of outline border color of Flutter textfield. 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 class. Using the color constructor of the border side class, we can change the color of the outline border of Flutter textfield. See the below code:

OutlineInputBorder(
            borderSide: BorderSide(color: Colors.green))
flutter textfield outline border custom color
flutter textfield widget outline border color
In the first image, you can see the custom color of outline enabled border and in the second image you can see the custom outline focused border color.
So in this way, you can change the Flutter textfield outline border color. You now have a practical understanding of how to change Flutter textfield outline border color. If you still have any doubts regarding this topic or any other then do let me know in the comment section. I would love to answer them.
As a treat, I have designed a beautiful custom Flutter textfield design for you in which Flutter textfield outline border color is also customized. The complete source code is available in the next block.

Custom Flutter Textfield Design Source Code

flutter textfield outline border color

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 StatefulWidget {
  @override
  State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      body: Center(
          child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 40),
              child: TextField(
                style: TextStyle(color: Colors.purple),
                decoration: InputDecoration(
                  enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(50)
                          .copyWith(bottomRight: Radius.circular(0)),
                      borderSide: BorderSide(color: Colors.purple)),
                  focusedBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(50)
                          .copyWith(bottomRight: Radius.circular(0)),
                      borderSide: BorderSide(color: Colors.purple)),
                ),
              ))),
    ));
  }
}

Conclusion

To conclude this tutorial, now you’ve a detailed and in-depth practical knowledge of how to implement Flutter textfield 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.

Leave a Comment

Your email address will not be published.