theme property

FThemeData get theme

Returns the current FThemeData, or FThemes.zinc.light if there is no ancestor FTheme.

Troubleshooting:

theme always returns FThemes.zinc.light

One of the most common causes is calling theme in the same context which FTheme was declared. To fix this, move the call to theme to a descendant widget.

✅ Do:

class Parent extends StatelessWidget {
  @override
  Widget build(BuildContext context) => FTheme(
     data: FThemes.zinc.light,
     child: Child(),
   );
 }

 class Child extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     final FThemeData theme = context.theme;
     return const SomeWidget(theme: theme);
   }
 }

❌ Do not:

class Parent extends StatelessWidget {
  @override
  Widget build(BuildContext context) => FTheme(
     data: FThemes.zinc.light,
     child: SomeWidget(
       theme: context.theme, // Whoops!
     ),
   );
 }

Implementation

FThemeData get theme => FTheme.of(this);