blueTheme function

ThemeData blueTheme({
  1. Color? dialogBackground,
  2. DialogThemeData? dialogTheme,
  3. Color? scaffoldBackgroundColor,
  4. AppBarTheme? appBarTheme,
  5. BottomAppBarTheme? bottomAppBarTheme,
  6. Color primaryColor = kPrimaryColor,
  7. ElevatedButtonThemeData? elevatedButtonThemeData,
  8. CheckboxThemeData? checkboxThemeData,
  9. Color mainTextColor = kMainTextColor,
  10. ColorScheme? colorScheme,
  11. Color? errorColor,
  12. InputDecorationTheme? inputDecorationTheme,
  13. TextStyle? regularFont,
  14. TextButtonThemeData? textButtonThemeData,
  15. IconButtonThemeData? iconButtonThemeData,
  16. TextSelectionThemeData? textSelectionThemeData,
})

Implementation

ThemeData blueTheme(
    {Color? dialogBackground,
    DialogThemeData? dialogTheme,
    Color? scaffoldBackgroundColor,
    AppBarTheme? appBarTheme,
    BottomAppBarTheme? bottomAppBarTheme,
    Color primaryColor = kPrimaryColor,
    ElevatedButtonThemeData? elevatedButtonThemeData,
    CheckboxThemeData? checkboxThemeData,
    Color mainTextColor = kMainTextColor,
    ColorScheme? colorScheme,
    Color? errorColor,
    InputDecorationTheme? inputDecorationTheme,
    TextStyle? regularFont,
    TextButtonThemeData? textButtonThemeData,
    IconButtonThemeData? iconButtonThemeData,
    TextSelectionThemeData? textSelectionThemeData}) {
  final Color errColor = errorColor ?? kErrorColor;
  final TextStyle regFont16 = regularFont ??
      TextStyle(fontFamily: _fontName, color: mainTextColor, fontSize: 16);
  const Color mainBackground = Color.fromRGBO(245, 245, 245, 1);
  return ThemeData(
    disabledColor: _secondSlateGrey,
    splashColor: Colors.transparent,
    highlightColor: Colors.transparent,
    textSelectionTheme: textSelectionThemeData ??
        TextSelectionThemeData(cursorColor: primaryColor),
    dialogTheme: dialogTheme ??
        DialogThemeData(
            surfaceTintColor: mainBackground,
            shape: const RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(5)))),
    scaffoldBackgroundColor: scaffoldBackgroundColor ?? mainBackground,
    appBarTheme: appBarTheme ?? const AppBarTheme(color: _secondSlateGrey),
    bottomAppBarTheme:
        bottomAppBarTheme ?? BottomAppBarTheme(color: primaryColor),
    primaryColor: primaryColor,
    elevatedButtonTheme: elevatedButtonThemeData ??
        ElevatedButtonThemeData(
          style: ButtonStyle(
            textStyle: WidgetStateProperty.all(const TextStyle(
              fontFamily: _fontName,
              fontWeight: FontWeight.w600,
              fontSize: 16.0,
              fontStyle: FontStyle.normal,
              color: mainBackground,
            )),
            foregroundColor: WidgetStateProperty.all(mainBackground),
            backgroundColor: WidgetStateProperty.resolveWith<Color>((states) {
              if (states.contains(WidgetState.disabled)) {
                return primaryColor.withValues(alpha: 0.5);
              }
              return primaryColor;
            }),
            shape: WidgetStateProperty.all<RoundedRectangleBorder>(
                const RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(6.0)),
            )),
            splashFactory: NoSplash.splashFactory,
          ),
        ),
    checkboxTheme: checkboxThemeData ??
        CheckboxThemeData(
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
            fillColor: WidgetStateProperty.resolveWith<Color>((states) {
              if (states.contains(WidgetState.selected)) {
                return primaryColor;
              }
              return kPrimaryWhite;
            }),
            splashRadius: 1,
            side: BorderSide(
                color: mainTextColor.withValues(alpha: 0.6), width: 2)),
    colorScheme: colorScheme ??
        ColorScheme(
          brightness: Brightness.light,
          primary: primaryColor,
          onPrimary: mainBackground,
          secondary: mainBackground,
          onSecondary: primaryColor,
          error: errColor,
          onError: errColor,
          surface: kPrimaryWhite,
          onSurface: mainTextColor,
        ),
    inputDecorationTheme: inputDecorationTheme ??
        InputDecorationTheme(
          errorMaxLines: 2,
          focusedBorder:
              UnderlineInputBorder(borderSide: BorderSide(color: primaryColor)),
          labelStyle:
              WidgetStateTextStyle.resolveWith((Set<WidgetState> states) {
            if (states.contains(WidgetState.focused)) {
              return regFont16.copyWith(
                  height: 15.5, color: regFont16.color!.withValues(alpha: 0.6));
            }
            return regFont16.copyWith(
                height: 1, color: regFont16.color!.withValues(alpha: 0.6));
          }),
          errorStyle: regFont16.copyWith(fontSize: 12.0, color: errColor),
          disabledBorder: const UnderlineInputBorder(
            borderSide: BorderSide(color: Colors.transparent),
          ),
          enabledBorder: UnderlineInputBorder(
              borderSide:
                  BorderSide(color: mainTextColor.withValues(alpha: 0.4))),
          alignLabelWithHint: true,
          contentPadding: const EdgeInsets.only(bottom: 2),
          isDense: true,
        ),
    textButtonTheme: textButtonThemeData ??
        TextButtonThemeData(
          style: ButtonStyle(
            padding: WidgetStateProperty.all(EdgeInsets.zero),
            textStyle: WidgetStateProperty.all(TextStyle(
              fontFamily: _fontName,
              fontWeight: FontWeight.w400,
              fontSize: 14.0,
              fontStyle: FontStyle.normal,
              color: mainTextColor,
            )),
            visualDensity: VisualDensity.compact,
            splashFactory: NoSplash.splashFactory,
          ),
        ),
    iconButtonTheme: iconButtonThemeData ??
        IconButtonThemeData(
            style: ButtonStyle(
                splashFactory: NoSplash.splashFactory,
                overlayColor: WidgetStateProperty.all(Colors.transparent))),
  );
}