我知道如何使用TextFormField
更改单个TextStyle
中的文本颜色,但我无法弄清楚如何使用主题在应用程序范围内应用它。
您需要将根小部件包装在Theme
中并按如下方式应用data
。 TextField
和TextFormField
都有相同的颜色,共同的主题。
Theme(
data: Theme.of(context).copyWith(
textTheme: Theme.of(context).textTheme.apply(bodyColor: Colors.green),
),
child: Column(
children: <Widget>[
TextFormField(...),
TextField(...),
],
),
);