theme_model.dart 547 B

12345678910111213141516171819202122232425
  1. import 'package:equatable/equatable.dart';
  2. import 'package:flowy_infra/theme.dart';
  3. import 'package:flutter/material.dart';
  4. class ThemeModel extends ChangeNotifier with EquatableMixin {
  5. ThemeType _theme = ThemeType.light;
  6. @override
  7. List<Object> get props {
  8. return [_theme];
  9. }
  10. ThemeType get theme => _theme;
  11. set theme(ThemeType value) {
  12. if (_theme != value) {
  13. _theme = value;
  14. notifyListeners();
  15. }
  16. }
  17. void swapTheme() {
  18. theme = (theme == ThemeType.light ? ThemeType.dark : ThemeType.light);
  19. }
  20. }