import 'package:flutter/material.dart'; import '../services/mark_list_service.dart'; class MarkListProvider extends ChangeNotifier { MarkListService? _service; List marks = []; bool loading = false; void init(BuildContext context) { _service = MarkListService(context); } Future loadMarks(BuildContext context) async { loading = true; notifyListeners(); _service ??= MarkListService(context); final res = await _service!.getMarks(); if (res['success'] == true) { marks = res['data'] ?? []; } loading = false; notifyListeners(); } Future> addMark(BuildContext context, String mark, String origin, String destination) async { _service ??= MarkListService(context); final res = await _service!.addMark({ "mark_no": mark, "origin": origin, "destination": destination }); if (res['success'] == true) { await loadMarks(context); // refresh list } return res; } }