activity status on sparepart activity and last situation in maintenance request added
parent
0d2e8d63b7
commit
f6b3c82fb3
@ -0,0 +1,36 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
import '../../controllers/api_routes/api_manager.dart';
|
||||||
|
import '../../controllers/api_routes/urls.dart';
|
||||||
|
import '../../models/lookup.dart';
|
||||||
|
|
||||||
|
class LastSituationProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getDate() async {
|
||||||
|
if (loading == true) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.getMaintenanceSituation);
|
||||||
|
stateCode = response.statusCode;
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
// client's request was successfully received
|
||||||
|
List categoriesListJson = json.decode(response.body)["data"];
|
||||||
|
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||||
|
}
|
||||||
|
loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return response.statusCode;
|
||||||
|
} catch (error) {
|
||||||
|
loading = false;
|
||||||
|
stateCode = -1;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue