You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
import 'dart:convert';
 | 
						|
 | 
						|
import 'package:http/http.dart';
 | 
						|
import 'package:test_sa/models/lookup.dart';
 | 
						|
 | 
						|
import '../../controllers/api_routes/api_manager.dart';
 | 
						|
import '../../controllers/api_routes/urls.dart';
 | 
						|
import 'loading_list_notifier.dart';
 | 
						|
 | 
						|
class PpmChecklistStatusProvider extends LoadingListNotifier<Lookup> {
 | 
						|
  @override
 | 
						|
  Future getDate() async {
 | 
						|
    if (loading ?? false) return -2;
 | 
						|
    loading = true;
 | 
						|
    notifyListeners();
 | 
						|
    Response response;
 | 
						|
    try {
 | 
						|
      response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
 | 
						|
    } catch (error) {
 | 
						|
      loading = false;
 | 
						|
      stateCode = -1;
 | 
						|
      notifyListeners();
 | 
						|
      return -1;
 | 
						|
    }
 | 
						|
    stateCode = response.statusCode;
 | 
						|
    if (response.statusCode >= 200 && response.statusCode < 300) {
 | 
						|
      // client's request was successfully received
 | 
						|
      List listJson = json.decode(response.body)["data"];
 | 
						|
      items = listJson.map((department) => Lookup.fromJson(department)).toList();
 | 
						|
    }
 | 
						|
    loading = false;
 | 
						|
    notifyListeners();
 | 
						|
    return response.statusCode;
 | 
						|
  }
 | 
						|
}
 |