54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
import 'package:cheminova/constants/constant.dart';
|
|
import 'package:cheminova/models/rejected_applicaton_response.dart';
|
|
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../services/api_client.dart';
|
|
import '../services/api_urls.dart';
|
|
|
|
class RejectedProvider extends ChangeNotifier {
|
|
RejectedProvider() {
|
|
getRejectedApplication();
|
|
}
|
|
final _apiClient = ApiClient();
|
|
RejectedApplicationResponse? rejectedApplicationResponse;
|
|
List<RejectedApplicationResponse> rejectedApplicationList = [];
|
|
|
|
bool _isLoading = false;
|
|
|
|
bool get isLoading => _isLoading;
|
|
|
|
void setLoading(bool loading) {
|
|
_isLoading = loading;
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<void> getRejectedApplication() async {
|
|
setLoading(true);
|
|
try {
|
|
Response response = await _apiClient.get(ApiUrls.rejectedApplication);
|
|
setLoading(false);
|
|
if (response.statusCode == 200) {
|
|
rejectedApplicationList = (response.data as List)
|
|
.map((e) => RejectedApplicationResponse.fromJson(e))
|
|
.toList();
|
|
notifyListeners();
|
|
}
|
|
} catch (e) {
|
|
String error = "Something went wrong";
|
|
if (e is DioException) {
|
|
error = e.response!.data['message'] ?? "Something went wrong";
|
|
}
|
|
ScaffoldMessenger.of(
|
|
navigatorKey.currentContext!,
|
|
).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
error,
|
|
),
|
|
),
|
|
);
|
|
setLoading(false);
|
|
}
|
|
}
|
|
}
|