connect with backend

This commit is contained in:
Abhishek Mali
2025-12-03 11:57:05 +05:30
parent c6b4c66c10
commit 3bf27cc29d
48 changed files with 2618 additions and 126 deletions

View File

@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import '../services/mark_list_service.dart';
class MarkListProvider extends ChangeNotifier {
MarkListService? _service;
List<dynamic> marks = [];
bool loading = false;
void init(BuildContext context) {
_service = MarkListService(context);
}
Future<void> 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<Map<String, dynamic>> 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;
}
}