How To Change Flutter Textformfield Hint Text Color?

flutter textformfield hint text color

Flutter textformfield hint text color customization. In this article, I will be implementing the customization of Flutter textformfield hint text color. I will also explain what Flutter hint text is and how you can change Flutter textformfield hint text color using step by step explanation with proper Flutter example code. So let’s get directly into how to change Flutter textformfield hint text color.

What is Flutter Textformfield Hint Text Color?

Flutter textformfield hint text color is as the name suggests, it is the color of the hint text in Flutter textformfield. Hint text is used to give hint to the user about what input should it give to the Flutter textformfield. Let’s now understand how to change Flutter textformfield hint text color using an easy Flutter example code.

Default Flutter Textformfield Hint Text Color

Let’s see the default Flutter textformfield hint text color, for that we have to use the decoration constructor of the Flutter textformfield then passing it the input decoration class. Now by using the hint text constructor and passing it a string, we can see the default Flutter textformfield hint text color. See the below code:

TextFormField(
        decoration:
              InputDecoration(hintText: 'Default hint text color')
               )
flutter textformfield default hint text color
You can see in the above image the default Flutter textformfield hint text color.

Change Flutter Textformfield Hint Text Color

Now let’s change the Flutter textformfield hint text color, for that we have to use the hint style constructor of the input decoration class. Then passing it text style class and by using its color constructor we can change the hint text color of the Flutter textformfield. See the below code for implementation:

 decoration: InputDecoration(
                   hintText: 'Custom hint text color',
                      hintStyle: TextStyle(color: Colors.red))
flutter textformfield hint text color

In the above image, you can see that the color of the hint text is now changed. I have used the red color to demonstrate that the Flutter textformfield hint text color is changed.

Congrats, you made it to the end. Hope you now have a complete practical understanding of how to change Flutter textformfield hint text color in Flutter textformfield. If you still have any queries then comment it down. Now as a treat, I have prepared a custom beautiful Flutter textformfield design for you in which Flutter textformfield hint text color is also customized. The complete source code is available in the next section.

Custom Flutter Textformfield Design Source Code

flutter textformfield hint text 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 StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      body: Center(
          child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 40),
              child: TextFormField(
                  style: TextStyle(color: Colors.white, fontSize: 20),
                  cursorColor: Colors.blue,
                  decoration: InputDecoration(
                    filled: true,
                    fillColor: Colors.blue.withOpacity(.4),
                    hintText: 'Custom hint text color',
                    hintStyle: TextStyle(color: Colors.white),
                    prefixIcon: Icon(
                      Icons.person,
                      color: Colors.white,
                    ),
                    border: InputBorder.none,
                    enabledBorder: OutlineInputBorder(
                        borderSide: BorderSide(color: Colors.blue),
                        borderRadius: BorderRadius.circular(30).copyWith(
                            topRight: Radius.circular(0),
                            topLeft: Radius.circular(0))),
                    focusedBorder: OutlineInputBorder(
                        borderSide: BorderSide(color: Colors.blue),
                        borderRadius: BorderRadius.circular(30).copyWith(
                            topRight: Radius.circular(0),
                            topLeft: Radius.circular(0))),
                    contentPadding: EdgeInsets.all(23),
                  )))),
    ));
  }
}

Conclusion

In conclusion, hope you now have a complete understanding of the customization of Flutter textformfield hint text color. I would love to have your feedback on this post. I would also love to see you visit my other posts on Flutter app development, Flutter widgets, Flutter animations, Flutter widgets and many more, links to some of these posts are listed below. That’s it for this post. Thanks for reading.

Leave a Comment

Your email address will not be published.