Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lib/providers/theme_provider.dart
- import 'package:flutter/material.dart';
- class ThemeProvider with ChangeNotifier {
- // Default theme is light
- ThemeMode _themeMode = ThemeMode.light;
- ThemeMode get themeMode => _themeMode;
- bool get isDarkMode => _themeMode == ThemeMode.dark;
- void toggleTheme(bool isOn) {
- _themeMode = isOn ? ThemeMode.dark : ThemeMode.light;
- notifyListeners();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement