0

I need to change label and border's default color to use the primary color on focus, and i've already tried InputDecorationTheme, but it doesn't work well with the label. I realize that the TextField uses accent color.

The screen; and theme:

final ThemeData darkTheme = ThemeData(
    primaryColor: Colors.blueAccent[400],
    accentColor: Colors.pinkAccent[400],
    brightness: Brightness.dark,
    backgroundColor: Colors.grey[900],
    inputDecorationTheme: InputDecorationTheme(
        fillColor: Colors.white.withOpacity(0.1),
        filled: true,
    ),
);

Thank you.

3 Answers3

0

Try setting the style in your TextFormField like:

style: TextStyle(
   color: Theme.of(context).primaryColor
),
Davide Bicego
  • 562
  • 2
  • 6
  • 24
0

utils.dart

class AvailableFonts {
  static const primaryFont = "Quicksand";
  static const primaryFontSize = 14.0;
}

theme.dart

place it in lib folder as main

ThemeData buildThemeData() {
  final baseTheme = ThemeData(fontFamily: AvailableFonts.primaryFont);

 return baseTheme.copyWith(
   primaryColor: primaryColor,
   primaryColorDark: primaryDark,
   primaryColorLight: primaryLight,
   accentColor: secondaryColor,
);}

And, where you define your colours

colours.dart

const primaryColor = Colors.red;
const primaryLight = const Color(0xFFB71C1C);
const primaryDark = const Color(0xFFFF9F59);
const secondaryColor = Colors.white;

There after, you can simply use as an example bellow:

color: primaryColor,

Daniel
  • 478
  • 3
  • 16
  • 32
0

This is the correct way to call color:

focusedBorder: UnderlineInputBorder(
                      borderRadius: BorderRadius.circular(20),
                      borderSide: BorderSide(
                          color: ThemeData()
                              .inputDecorationTheme
                              .focusedBorder?.borderSide
                              .color ??
                              Colors.pink),
                    )
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103