getTheme function Null safety

dynamic getTheme(
  1. BuildContext context
)

return the theme data according to theme mode (Dark/Light)

Implementation

getTheme(BuildContext context)  {
  var defaultTheme = Theme.of(context);
  return {
    AppThemeMode.LIGHT : ThemeData(
        brightness: Brightness.light,
        primaryColor: palette[400],
        accentColor: palette[400],
        primarySwatch: MaterialColor(0xFFFF256E, palette),
        textTheme: GoogleFonts.poppinsTextTheme(
            TextTheme(
              headline1: defaultTheme.textTheme.headline1,
              headline2: defaultTheme.textTheme.headline2,
              headline3: defaultTheme.textTheme.headline3,
              headline4: defaultTheme.textTheme.headline4,
              headline5: defaultTheme.textTheme.headline5,
              headline6: defaultTheme.textTheme.headline6,
              bodyText1: defaultTheme.textTheme.bodyText1,
              bodyText2: defaultTheme.textTheme.bodyText2,
              subtitle1: defaultTheme.textTheme.subtitle1,
              subtitle2: defaultTheme.textTheme.subtitle2,
              caption: defaultTheme.textTheme.caption,
              button:  defaultTheme.textTheme.button,
                overline:  defaultTheme.textTheme.overline
            )
        ),
        scaffoldBackgroundColor: Color(0xFFebeef5),
        canvasColor: Color(0xFFebeef5),
        dividerColor: Color(0xFFdadde6),
        cardColor: Colors.white,
        hintColor: Color(0xFFCFCFCF),
        appBarTheme: AppBarTheme(
            elevation: 0,
            color: Colors.white,
            centerTitle: true,
            titleTextStyle: TextStyle(
                color: Colors.black54,
                letterSpacing: 2.0,
                fontSize: 18
            )
        ),
      iconTheme:  IconThemeData(size: defaultTheme.iconSize5x, color: Colors.black87)
    ),
    AppThemeMode.DARK : ThemeData(
      brightness: Brightness.dark,
      primaryColor: palette[400],
      accentColor: palette[400],
      primarySwatch: MaterialColor(0xFFFF256E, palette),
      textTheme: GoogleFonts.poppinsTextTheme(
        TextTheme(
            headline1: defaultTheme.textTheme.headline1!.apply(color: Colors.white),
            headline2: defaultTheme.textTheme.headline2!.apply(color: Colors.white),
            headline3: defaultTheme.textTheme.headline3!.apply(color: Colors.white),
            headline4: defaultTheme.textTheme.headline4!.apply(color: Colors.white),
            headline5: defaultTheme.textTheme.headline5!.apply(color: Colors.white),
            headline6: defaultTheme.textTheme.headline6!.apply(color: Colors.white),
            bodyText1: defaultTheme.textTheme.bodyText1!.apply(color: Colors.white),
            bodyText2: defaultTheme.textTheme.bodyText2!.apply(color: Colors.white70),
            subtitle1: defaultTheme.textTheme.subtitle1!.apply(color: Colors.white),
            subtitle2: defaultTheme.textTheme.subtitle2!.apply(color: Colors.white70),
            caption: defaultTheme.textTheme.caption!.apply(color: Colors.white60),
            button:  defaultTheme.textTheme.button,
            overline:  defaultTheme.textTheme.overline
        )
      ),
      dividerColor: Colors.white30,
      cardColor: Color(0xFF222b45),
      scaffoldBackgroundColor: Color(0xFF1a2138),
      canvasColor: Color(0xFF1a2138),
      hintColor: Colors.white60,
      appBarTheme: AppBarTheme(
        elevation: 0,
        color: Color(0xFF222b45),
        centerTitle: true,
        titleTextStyle: TextStyle(
          color: Colors.white,
          letterSpacing: 2.0,
          fontSize: 18
        )
        ),
        iconTheme:  IconThemeData(size: defaultTheme.iconSize5x, color: Colors.white70)
    ),
  };
}