import 'dart:convert'; import 'package:get/get.dart'; import 'package:sefer_admin1/constant/links.dart'; import 'package:sefer_admin1/controller/functions/crud.dart'; import '../../print.dart'; class FinancialV2Controller extends GetxController { bool isLoading = true; Map stats = {}; List settlements = []; @override void onInit() { super.onInit(); fetchAllFinancials(); } Future fetchAllFinancials() async { isLoading = true; update(); await Future.wait([ fetchStats(), fetchSettlements(), ]); isLoading = false; update(); } Future fetchStats() async { try { var res = await CRUD().get(link: AppLink.financialStatsV2, payload: {}); if (res != 'failure' && res != null) { var d = res is String ? jsonDecode(res) : res; if (d['status'] == 'success') { stats = d['data']; } } } catch (e) { Log.print('Error fetching financial stats: $e'); } } Future fetchSettlements() async { try { var res = await CRUD().get(link: AppLink.settlementsV2, payload: {}); if (res != 'failure' && res != null) { var d = res is String ? jsonDecode(res) : res; if (d['status'] == 'success') { settlements = d['data']; } } } catch (e) { Log.print('Error fetching settlements: $e'); } } }