Flutter - How to change TextField hint color?

后端 未结 3 1262
日久生厌
日久生厌 2021-01-31 14:15

I\'m a bit confused how to change the hint color of the textfield. Someone can guide me how to do it.Thanks

child: TextField(
   style: TextStyle(fontSize: 20),
         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 14:46

    As an addition to the accepted answer, to update the focused hint decoration you have to update the app's Theme.

    @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
              primaryColor: Colors.white,
              inputDecorationTheme: const InputDecorationTheme(
                labelStyle: TextStyle(color: Colors.black),
                hintStyle: TextStyle(color: Colors.grey),
              )),
          home: MainScreen(),
        );
      }
    

提交回复
热议问题