import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'app_theme.dart'; class ThemeProvider with ChangeNotifier { ThemeType _currentTheme = ThemeType.defaultTheme; static const String _themeKey = 'theme_type'; ThemeType get currentTheme => _currentTheme; ThemeProvider() { _loadTheme(); } Future _loadTheme() async { final prefs = await SharedPreferences.getInstance(); final themeIndex = prefs.getInt(_themeKey) ?? 0; _currentTheme = ThemeType.values[themeIndex]; notifyListeners(); } Future setTheme(ThemeType theme) async { _currentTheme = theme; final prefs = await SharedPreferences.getInstance(); await prefs.setInt(_themeKey, theme.index); notifyListeners(); } bool get isDarkMode => _currentTheme == ThemeType.darkTheme; }