connect with backend
This commit is contained in:
23
lib/providers/invoice_provider.dart
Normal file
23
lib/providers/invoice_provider.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user