ThemeProvider constructor

ThemeProvider({
  1. Key? key,
  2. String providerId = "default",
  3. List<AppTheme>? themes,
  4. String? defaultThemeId,
  5. ThemeControllerHandler? onInitCallback,
  6. ThemeChanged? onThemeChanged,
  7. required Widget child,
  8. bool saveThemesOnChange = false,
  9. bool loadThemeOnInit = false,
})

Creates a ThemeProvider. Wrap MaterialApp in ThemeProvider to get theme functionalities. You may wrap separate parts of the app with multiple ThemeProviders to use multiple theme sections across the app.

If you did not specify default themes, it would default to the light and dark themes.

Implementation

ThemeProvider({
  Key? key,
  this.providerId = "default",
  List<AppTheme>? themes,
  this.defaultThemeId,
  this.onInitCallback,
  this.onThemeChanged,
  required this.child,
  this.saveThemesOnChange = false,
  this.loadThemeOnInit = false,
})  : this.themes = themes ?? [AppTheme.light(), AppTheme.dark()],
      super(key: key) {
  assert(this.themes.length >= 2, "Theme list must have at least 2 themes.");
}