44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:cheminova/models/select_task_response.dart';
|
|
import 'package:dio/dio.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../services/api_client.dart';
|
|
import '../services/api_urls.dart';
|
|
|
|
class SelectTaskProvider extends ChangeNotifier {
|
|
SelectTaskProvider() {
|
|
getTask();
|
|
}
|
|
|
|
final _apiClient = ApiClient();
|
|
List<Tasks> tasksList=[];
|
|
|
|
bool _isLoading = false;
|
|
|
|
bool get isLoading => _isLoading;
|
|
|
|
void setLoading(bool loading) {
|
|
_isLoading = loading;
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<void> getTask() async {
|
|
setLoading(true);
|
|
try {
|
|
Response response = await _apiClient.get(ApiUrls.selectTaskUrl);
|
|
setLoading(false);
|
|
if (response.statusCode == 200) {
|
|
final data = SelectTaskKycResponse.fromJson(response.data);
|
|
tasksList = data.tasks ?? [];
|
|
notifyListeners();
|
|
}
|
|
} catch (e) {
|
|
setLoading(false);
|
|
if (kDebugMode) {
|
|
print("Error occurred while fetching notifications: $e");
|
|
}
|
|
}
|
|
}
|
|
}
|