-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.dart
30 lines (25 loc) · 947 Bytes
/
preferences.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import 'package:shared_preferences/shared_preferences.dart';
class Preferences {
int lowQuantity = 1;
int daysBeforeExpiry = 1;
void setLowQuantity(int newQuantity) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setInt('lowQuantity', newQuantity);
lowQuantity = newQuantity;
}
Future<int> getLowQuantity() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
lowQuantity = prefs.getInt('lowQuantity') ?? 0;
return lowQuantity;
}
void setDaysBeforeExpiry(int newValue) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setInt('daysBeforeExpiry', newValue);
daysBeforeExpiry = newValue;
}
Future<int> getDaysBeforeExpiry() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
daysBeforeExpiry = prefs.getInt('daysBeforeExpiry') ?? 1;
return daysBeforeExpiry;
}
}