flutter 文本表单字段的设计(focusColor和cursorColor)

8yoxcaq7  于 2023-02-13  发布在  Flutter
关注(0)|答案(1)|浏览(189)

嘿,在我的应用程序中,我有一些TextFormField。我想用MaterialApp()中的一个主题来定义它们的主题。我读到过FocusColor是次要颜色,但在我的情况下,focusColor是青色,尽管我从未定义过。下面是我的主题:

runApp(MaterialApp(
  theme: theme.copyWith(
    colorScheme: theme.colorScheme.copyWith(
      primary: globals.primaryColor,
      secondary: globals.highlightColor,
      background: globals.backgroundColor,
    ),
  ),
));

下面是我的文本表单字段:

TextFormField(
  style: TextStyle(color: globals.darkText, fontWeight: FontWeight.bold),
  decoration: textInputDecoration.copyWith(
    hintText: "Name",
    hintStyle: TextStyle(color: globals.backgroundColor, fontWeight: FontWeight.bold),
    focusColor: globals.highlightColor,
    fillColor: globals.primaryColor,
  ),
  onSaved: (input) => _name = input,
),

另外,光标总是深蓝色的,我也不知道该在哪里改变颜色。谢谢你的回答!

06odsfpq

06odsfpq1#

请尝试使用此:

textSelectionTheme: const TextSelectionThemeData(cursorColor: MyColor.kGreen)

相关问题