Flutter 有没有办法在Flatter中的InputEdition中设置文本的颜色?

Flutter 有没有办法在Flatter中的InputEdition中设置文本的颜色?,flutter,dart,Flutter,Dart,在HTML中 *用户名 在html标记中放置红色*字符很容易 但在飘动中 TextFormField maxLines:1, 键盘类型:TextInputType.text, 自动对焦:错误, 装饰:输入装饰 hintText:'用户名', labelText:“*用户名”, initialValue:_userProfileDataMap['userName'], 这适用于带标签的TextFormField,仅允许字符串输出 如何尝试使用HTML样式?设置一个hintStyle以更改标签文本颜

在HTML中

*用户名 在html标记中放置红色*字符很容易

但在飘动中

TextFormField maxLines:1, 键盘类型:TextInputType.text, 自动对焦:错误, 装饰:输入装饰 hintText:'用户名', labelText:“*用户名”, initialValue:_userProfileDataMap['userName'], 这适用于带标签的TextFormField,仅允许字符串输出

如何尝试使用HTML样式?

设置一个hintStyle以更改标签文本颜色

decoration: InputDecoration(
    hintText: 'Username',
    hintStyle: TextStyle(color: Colors.red),
),
decoration: InputDecoration(
    hintText: 'User Name',
    labelText: 'User Name',
    labelStyle: TextStyle(color: Colors.red),
),
标签文本分为两个阶段,当标签文本位于输入字段顶部时,将使用hintStyle;当标签文本位于输入字段上方时,即垂直上方而非上方时,需要使用如下标签样式:

labelStyle: TextStyle(color: Colors.red),
因此,将两者结合使用:

decoration: InputDecoration(
    hintText: 'Enter your username',
    labelText: 'Username'
    hintStyle: TextStyle(color: Colors.red),
    labelStyle: TextStyle(color: Colors.red),
),
设置标签样式以更改标签文本颜色

decoration: InputDecoration(
    hintText: 'Username',
    hintStyle: TextStyle(color: Colors.red),
),
decoration: InputDecoration(
    hintText: 'User Name',
    labelText: 'User Name',
    labelStyle: TextStyle(color: Colors.red),
),

下面是您的答案。style:TextStyle color:Colors.white代表值,而不是特定的标签。现在标签只能设置字符串类型,如果您可以设置小部件,则应该有更多自定义空格。我在flatter中询问了“*”。不whole@YangJaeLee可以使用定义不同单词的不同样式,但我不知道是否可以在labelText中使用它,因为labelText接受字符串而不是小部件。一些人建议使用这个软件包进行富文本样式设置,您可能想查看一下它是否有帮助。