import 'package:flutter/cupertino.dart'; import 'package:gen_service/Services/api_calling.dart'; import '../Models/TransactionListResponse.dart'; class TransactionsProvider with ChangeNotifier { bool _isLoading = false; String? _errorMessage; TransactionListResponse? _transactionList; bool get isLoading => _isLoading; String? get errorMessage => _errorMessage; TransactionListResponse? get transactionList => _transactionList; /// Fetch Transactions from API Future fetchTransactions(String accId, String sessionId) async { _isLoading = true; _errorMessage = null; notifyListeners(); try { final response = await ApiCalling.fetchTransactionListApi(accId, sessionId); if (response != null) { _transactionList = response; _errorMessage = null; } else { _errorMessage = "No response from server"; } } catch (e) { _errorMessage = "Failed to fetch transactions: $e"; } _isLoading = false; notifyListeners(); } /// Clear Data void clearTransactions() { _transactionList = null; _errorMessage = null; notifyListeners(); } }