| 1234567891011121314151617181920 |
- import 'package:flutter/material.dart';
- import 'profile.dart';
- import '../common/global.dart';
- class ThemeModel extends ProfilePresenter {
- // 获取当前主题,如果为设置主题,则默认使用蓝色主题
- MaterialColor get theme => Global.themes
- .firstWhere((e) => e.value == profile.theme, orElse: () => Colors.blue);
- // 主题改变后,通知其依赖项,新主题会立即生效
- set theme(MaterialColor color) {
- if (color != theme) {
- profile.theme = color.shade500.value;
- notifyListeners();
- }
- }
- }
|