24 lines
566 B
Dart
24 lines
566 B
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import '../services/invoice_service.dart';
|
||
|
|
import '../services/dio_client.dart';
|
||
|
|
|
||
|
|
class InvoiceProvider extends ChangeNotifier {
|
||
|
|
bool loading = false;
|
||
|
|
List invoices = [];
|
||
|
|
|
||
|
|
Future<void> loadInvoices(BuildContext context) async {
|
||
|
|
loading = true;
|
||
|
|
notifyListeners();
|
||
|
|
|
||
|
|
final service = InvoiceService(DioClient.getInstance(context));
|
||
|
|
final res = await service.getAllInvoices();
|
||
|
|
|
||
|
|
if (res['success'] == true) {
|
||
|
|
invoices = res['invoices'] ?? [];
|
||
|
|
}
|
||
|
|
|
||
|
|
loading = false;
|
||
|
|
notifyListeners();
|
||
|
|
}
|
||
|
|
}
|