import 'package:flutter/material.dart';
import 'package:nearle/Models/summary/riderweeklykms.dart';
import 'package:nearle/controllers/riderkm.dart';


class RiderWeeklyKmProvider extends ChangeNotifier {
  final RiderWeeklyKmController _controller = RiderWeeklyKmController();

  bool isLoading = false;
  String? error;
  List<RiderWeeklyKms> kmsList = [];
  double totalKms = 0.0;

  Future<void> fetchRiderWeeklyKms(int userId) async {
    isLoading = true;
    error = null;
    notifyListeners();

    try {
      final result = await _controller.getRiderWeeklyKms(userId);
      kmsList = result['details'];
      totalKms = result['total_kms'];
    } catch (e) {
      error = e.toString();
    }

    isLoading = false;
    notifyListeners();
  }
}


