mirror of
https://github.com/hmalik144/easy_cc_flutter.git
synced 2026-03-18 07:35:54 +00:00
Ability to cache currency selection
This commit is contained in:
6
lib/data/prefs/CurrencyPair.dart
Normal file
6
lib/data/prefs/CurrencyPair.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
class CurrencyPair {
|
||||
String? currencyOne;
|
||||
String? currencyTwo;
|
||||
|
||||
CurrencyPair(this.currencyOne, this.currencyTwo);
|
||||
}
|
||||
27
lib/data/prefs/PreferenceProvider.dart
Normal file
27
lib/data/prefs/PreferenceProvider.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'CurrencyPair.dart';
|
||||
|
||||
const String CURRENCY_ONE = "conversion_one";
|
||||
const String CURRENCY_TWO = "conversion_two";
|
||||
class PreferenceProvider {
|
||||
late final SharedPreferences _prefs;
|
||||
|
||||
Future<void> init() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
Future<void> saveConversionPair(String s1, String s2) async {
|
||||
await _prefs.setString(CURRENCY_ONE, s1);
|
||||
await _prefs.setString(CURRENCY_TWO, s2);
|
||||
}
|
||||
|
||||
CurrencyPair getConversionPair() {
|
||||
String? s1 = _prefs.getString(CURRENCY_ONE);
|
||||
String? s2 = _prefs.getString(CURRENCY_TWO);
|
||||
|
||||
return CurrencyPair(s1, s2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user