registerThemes<T> method
Register themes with the manager.
themes - List of theme configurations to register.
initialThemeId - Optional theme ID to use on first launch. If provided,
it will disable system theme following.
If not provided, the system brightness will be used
to select a matching theme.
Implementation
void registerThemes<T>(
List<BaseThemeConfig<T>> themes, {
String? initialThemeId,
}) {
_themes.clear();
_themes.addAll(themes);
if (_themes.isEmpty) {
throw ArgumentError('At least one theme must be registered.');
}
// Store initial theme ID for use in init()
_initialThemeId = initialThemeId;
// If initialThemeId is provided, disable follow system theme
if (initialThemeId != null && initialThemeId.isNotEmpty) {
_followSystemTheme = false;
final themeExists = _themes.any((t) => t.id == initialThemeId);
if (themeExists) {
_setThemeInternal(initialThemeId, notify: false, persist: false);
} else {
_setThemeInternal(_themes.first.id, notify: false, persist: false);
}
} else {
// Auto-detect from system brightness
_applySystemTheme(notify: false, persist: false);
}
}