First commit

This commit is contained in:
Van Leemput Dayron
2025-09-30 15:53:48 +02:00
commit 807b66f919
145 changed files with 6206 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ThemeProvider extends ChangeNotifier {
ThemeMode _themeMode = ThemeMode.system;
ThemeMode get themeMode => _themeMode;
bool get isDarkMode {
if (_themeMode == ThemeMode.system) {
return WidgetsBinding.instance.window.platformBrightness ==
Brightness.dark;
}
return _themeMode == ThemeMode.dark;
}
ThemeProvider() {
_loadThemeMode();
}
void setThemeMode(ThemeMode themeMode) async {
_themeMode = themeMode;
notifyListeners();
// Sauvegarder la préférence
final prefs = await SharedPreferences.getInstance();
await prefs.setString('themeMode', themeMode.toString());
}
void _loadThemeMode() async {
final prefs = await SharedPreferences.getInstance();
final themeModeString = prefs.getString('themeMode');
if (themeModeString != null) {
switch (themeModeString) {
case 'ThemeMode.light':
_themeMode = ThemeMode.light;
break;
case 'ThemeMode.dark':
_themeMode = ThemeMode.dark;
break;
case 'ThemeMode.system':
default:
_themeMode = ThemeMode.system;
break;
}
notifyListeners();
}
}
}