Skip to content
Snippets Groups Projects
Commit 97e6d5aa authored by Florian's avatar Florian
Browse files

sample data only loaded, when opening first time

parent 760c8576
No related branches found
No related tags found
No related merge requests found
......@@ -55,14 +55,15 @@ Future<void> setupLocatorService() async {
Box<Transaction> transactionsBox = await Hive.openBox<Transaction>('transactions_box');
// TODO: remove for prod, only here for dev/test purposes
await transactionsBox.clear();
List<Transaction> transactionsFromJson = [];
final String response = await rootBundle.loadString('assets/data/transaction_data.json');
final jsonList = await json.decode(response);
for(var json in jsonList) {
transactionsFromJson.add(Transaction.fromJson(json));
if(appState.isFirstOpening) {
List<Transaction> transactionsFromJson = [];
final String response = await rootBundle.loadString('assets/data/transaction_data.json');
final jsonList = await json.decode(response);
for(var json in jsonList) {
transactionsFromJson.add(Transaction.fromJson(json));
}
transactionsBox.addAll(transactionsFromJson);
}
transactionsBox.addAll(transactionsFromJson);
double balance = 0;
double income = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment