Files
kent_logistics_app/lib/providers/dashboard_provider.dart

40 lines
991 B
Dart
Raw Normal View History

2025-12-03 11:57:05 +05:30
import 'package:flutter/material.dart';
import '../services/dashboard_service.dart';
class DashboardProvider extends ChangeNotifier {
DashboardService? _service;
bool loading = false;
int activeOrders = 0;
int inTransitOrders = 0;
int deliveredOrders = 0;
String totalValue = "0";
double totalRaw = 0;
void init(BuildContext context) {
_service = DashboardService(context);
}
Future<void> loadSummary(BuildContext context) async {
loading = true;
notifyListeners();
_service ??= DashboardService(context);
final res = await _service!.getSummary();
if (res['status'] == true) {
final s = res['summary'];
activeOrders = s['active_orders'] ?? 0;
inTransitOrders = s['in_transit_orders'] ?? 0;
deliveredOrders = s['delivered_orders'] ?? 0;
totalValue = s['total_value']?.toString() ?? "0";
totalRaw = double.tryParse(s['total_raw'].toString()) ?? 0;
}
loading = false;
notifyListeners();
}
}