import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:kmobile/config/theme_type.dart'; class ThemeController with ChangeNotifier { ThemeType _currentTheme = ThemeType.violet; ThemeType get currentTheme => _currentTheme; Future loadTheme() async { final prefs = await SharedPreferences.getInstance(); final savedTheme = prefs.getString('color_theme'); if (savedTheme != null) { _currentTheme = ThemeType.values.firstWhere( (e) => e.name == savedTheme, orElse: () => ThemeType.violet, ); notifyListeners(); } } Future setTheme(ThemeType theme) async { _currentTheme = theme; notifyListeners(); final prefs = await SharedPreferences.getInstance(); await prefs.setString('color_theme', theme.name); } }