You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							31 lines
						
					
					
						
							955 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							31 lines
						
					
					
						
							955 B
						
					
					
				| import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; | |
| import 'package:hadi_hoda_flutter/core/utils/local_storage.dart'; | |
| import 'package:flutter/material.dart'; | |
| 
 | |
| class ThemeService { | |
|   static const ThemeService _i = ThemeService._internal(); | |
|   const ThemeService._internal(); | |
|   factory ThemeService() => _i; | |
| 
 | |
|   static void changeTheme({required ThemeMode themeMode}) { | |
|     switch (themeMode) { | |
|       case ThemeMode.dark: | |
|         LocalStorage.saveData(key: MyConstants.theme, value: 'dark'); | |
|       case ThemeMode.light: | |
|         LocalStorage.saveData(key: MyConstants.theme, value: 'light'); | |
|       default: | |
|         LocalStorage.saveData(key: MyConstants.theme, value: 'system'); | |
|     } | |
|   } | |
| 
 | |
|   static ThemeMode getTheme() { | |
|     switch (LocalStorage.readData(key: MyConstants.theme)) { | |
|       case 'dark': | |
|         return ThemeMode.dark; | |
|       case 'light': | |
|         return ThemeMode.light; | |
|       default: | |
|         return ThemeMode.light; | |
|     } | |
|   } | |
| } |