LCOV - code coverage report
Current view: top level - lib/_classes/herald - app_theme.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 2 13 15.4 %
Date: 2024-10-04 11:09:33 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2023 The terCAD team. All rights reserved.
       2             : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3             : 
       4             : import 'package:app_finance/_classes/storage/app_preferences.dart';
       5             : import 'package:flutter/material.dart';
       6             : 
       7             : class AppTheme extends ValueNotifier<ThemeMode> {
       8           3 :   AppTheme(super.value) {
       9           3 :     final val = AppPreferences.get(AppPreferences.prefTheme);
      10             :     if (val != null) {
      11           0 :       _set(val);
      12             :     }
      13             :   }
      14             : 
      15           0 :   _set(String val) {
      16           0 :     int? idx = int.tryParse(val);
      17           0 :     if (idx != null && idx < ThemeMode.values.length) {
      18           0 :       final newValue = ThemeMode.values[idx];
      19           0 :       if (newValue != value) {
      20           0 :         value = newValue;
      21           0 :         notifyListeners();
      22             :       }
      23             :     }
      24             :   }
      25             : 
      26           0 :   Future<void> setTheme(String value) async {
      27           0 :     await AppPreferences.set(AppPreferences.prefTheme, value);
      28           0 :     _set(value);
      29             :   }
      30             : }

Generated by: LCOV version 1.14