Advertisement
amonnoris

theme_provider.dart

Oct 5th, 2024
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.42 KB | Source Code | 0 0
  1. // lib/providers/theme_provider.dart
  2.  
  3. import 'package:flutter/material.dart';
  4.  
  5. class ThemeProvider with ChangeNotifier {
  6.   // Default theme is light
  7.   ThemeMode _themeMode = ThemeMode.light;
  8.  
  9.   ThemeMode get themeMode => _themeMode;
  10.  
  11.   bool get isDarkMode => _themeMode == ThemeMode.dark;
  12.  
  13.   void toggleTheme(bool isOn) {
  14.     _themeMode = isOn ? ThemeMode.dark : ThemeMode.light;
  15.     notifyListeners();
  16.   }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement