Skip to content

Instantly share code, notes, and snippets.

@mortezanazari-hub
Created January 23, 2025 13:35
Show Gist options
  • Select an option

  • Save mortezanazari-hub/df05a20910a6953e407adfe3bd9315ca to your computer and use it in GitHub Desktop.

Select an option

Save mortezanazari-hub/df05a20910a6953e407adfe3bd9315ca to your computer and use it in GitHub Desktop.
/// {@template theme_scope}
/// InheritedWidget که [AppTheme] را برای برنامه فراهم می‌کند.
/// InheritedWidget provides [AppTheme] for app
/// {@endtemplate}
class ThemeScope extends InheritedWidget {
/// {@macro theme_scope}
const ThemeScope({
super.key,
required Widget child,
required this.themeMode,
required this.appTheme,
}) : super(child: child);
/// حالت تم فعلی.
/// The current theme mode.
final ThemeMode themeMode;
/// تم فعلی برنامه.
/// The current app theme.
final AppTheme appTheme;
/// تم فعلی.
/// The current theme.
static ThemeScope of(BuildContext context) {
final result = context.dependOnInheritedWidgetOfExactType<ThemeScope>();
assert(result != null, 'No ThemeScope found in context');
return result!;
}
@override
bool updateShouldNotify(ThemeScope oldWidget) => true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment