Can I use two ThemeData types?

180 views Asked by At

I am trying to use these two ThemeData types in my MaterialApp. Check it out:

return GetMaterialApp(
  debugShowCheckedModeBanner: false,
  title: 'DISH Connect',
  home: SiteLayout(),
  theme: ThemeData.light(),
  darkTheme: ThemeData.dark(),
  darkTheme: ThemeData(
    pageTransitionsTheme: PageTransitionsTheme(
      builders: {
        TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
        TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
      },
    ),
  ),
  themeMode: provider.themeMode,
);

You can see that for my normal theme option, I have ThemeData.light(). I want to do the same for dark (which means I have to do 'ThemeData.dark()'). But I also want to be able to declare my pageTransitionTheme for these.

How can I make this possible?

1

There are 1 answers

0
pszklarska On

You can use copyWith() method:

darkTheme: ThemeData.dark().copyWith(
  pageTransitionsTheme: PageTransitionsTheme(
    builders: {
      TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
      TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
    },
  ),
),