Line data Source code
1 : // Copyright 2024 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_data.dart'; 5 : import 'package:app_finance/_classes/structure/abstract_app_data.dart'; 6 : import 'package:app_finance/_classes/structure/account_app_data.dart'; 7 : import 'package:app_finance/_classes/structure/bill_app_data.dart'; 8 : import 'package:app_finance/_classes/structure/budget_app_data.dart'; 9 : import 'package:app_finance/_classes/structure/currency_app_data.dart'; 10 : import 'package:app_finance/_classes/structure/goal_app_data.dart'; 11 : import 'package:app_finance/_classes/structure/invoice_app_data.dart'; 12 : 13 : extension DataExt on String { 14 0 : AbstractAppData? toDataObject(Map<String, dynamic> data, AppData store) => switch (this) { 15 0 : 'GoalAppData' => GoalAppData.fromJson(data), 16 0 : 'AccountAppData' => AccountAppData.fromJson(data), 17 0 : 'BillAppData' => BillAppData.fromJson(data)..setState(store), 18 0 : 'BudgetAppData' => BudgetAppData.fromJson(data)..setState(store), 19 0 : 'CurrencyAppData' => CurrencyAppData.fromJson(data), 20 0 : 'InvoiceAppData' => InvoiceAppData.fromJson(data)..setState(store), 21 : _ => null, 22 : }; 23 : }