mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 09:41:13 +03:00
28 lines
777 B
Dart
28 lines
777 B
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import '../../core/constants.dart';
|
|
|
|
class AmountFormatNotifier extends Notifier<AmountFormat> {
|
|
@override
|
|
AmountFormat build() {
|
|
_load();
|
|
return AmountFormat.commasDot;
|
|
}
|
|
|
|
void _load() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final index = prefs.getInt('amount_format') ?? 0;
|
|
state = AmountFormat.values[index];
|
|
}
|
|
|
|
void set(AmountFormat format) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
state = format;
|
|
await prefs.setInt('amount_format', format.index);
|
|
}
|
|
}
|
|
|
|
final amountFormatProvider = NotifierProvider<AmountFormatNotifier, AmountFormat>(
|
|
AmountFormatNotifier.new,
|
|
);
|