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 AppZoom extends ValueNotifier<double> { 8 3 : static get state => double.tryParse(AppPreferences.get(AppPreferences.prefZoom) ?? '') ?? 1.0; 9 : static const double max = 2.0; 10 : static const double min = 0.6; 11 : 12 3 : AppZoom() : super(state); 13 : 14 0 : Future<void> set(double newValue) async { 15 0 : newValue = newValue.clamp(min, max); 16 0 : if (newValue != value) { 17 0 : value = newValue; 18 0 : await AppPreferences.set(AppPreferences.prefZoom, value.toString()); 19 0 : notifyListeners(); 20 : } 21 : } 22 : }