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 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(); } }