【问题标题】:Flutter TextFormField focused border colorFlutter TextFormField 焦点边框颜色
【发布时间】:2021-08-25 00:21:28
【问题描述】:

这是我的主题:

final ThemeData theme = ThemeData();

    return MaterialApp(
      title: 'Notes',
      home: SignInPage(),
      debugShowCheckedModeBanner: false,
      theme: theme.copyWith(
        primaryColor: Colors.green[800],
        colorScheme: theme.colorScheme
            .copyWith(secondary: Colors.green, secondaryVariant: Colors.green),
        floatingActionButtonTheme: FloatingActionButtonThemeData(
          backgroundColor: Colors.blue[900],
        ),
        inputDecorationTheme: InputDecorationTheme(
          border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(8),
          ),
        ),
      ),
    );

在过去的 Flutter 时代,如果您将原色设为绿色,则焦点文本字段的边框也会变为绿色。现在,我希望我的所有文本字段在聚焦时都有一个绿色边框、绿色前缀图标和绿色标签文本,所有这些都来自根主题。但这是我使用上面的代码得到的结果:

我希望锁定、“密码”标签和边框在聚焦时全部为绿色,而在未聚焦时为灰色。如何从应用程序的根主题执行此操作。我将 primaryColor 设置为绿色,甚至将 colorScheme 辅助颜色设置为绿色,但仍然是蓝色,而不是绿色。

【问题讨论】:

    标签: flutter dart flutter-layout material-design flutter-textinputfield


    【解决方案1】:

    现在更改整个文本字段颜色的实际方法是更改​​ colorScheme。

    colorScheme: theme.colorScheme.copyWith(
              primary: Colors.green,
            ),
    

    【讨论】:

      猜你喜欢
      • 2019-11-05
      • 2019-06-29
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 2022-11-27
      • 1970-01-01
      相关资源
      最近更新 更多