flutter_calculator/lib/theme_model.dart
2020-10-02 15:41:59 +03:00

24 lines
574 B
Dart

import 'package:flutter/material.dart';
import 'theme.dart';
enum ThemeType { lightTheme, darkTheme }
class ThemeModel extends ChangeNotifier {
ThemeData currentTheme = darkTheme;
ThemeType _themeType = ThemeType.darkTheme;
void toggleTheme() {
if (_themeType == ThemeType.darkTheme) {
currentTheme = lightTheme;
_themeType = ThemeType.lightTheme;
return notifyListeners();
}
if (_themeType == ThemeType.lightTheme) {
currentTheme = darkTheme;
_themeType = ThemeType.darkTheme;
return notifyListeners();
}
}
}