'Can I use two ThemeData types?
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?
Solution 1:[1]
You can use copyWith() method:
darkTheme: ThemeData.dark().copyWith(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
},
),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pszklarska |
