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.
44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:http/http.dart';
|
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
|
import 'package:test_sa/modules/loan_module/models/loan_request_model.dart';
|
|
import 'dart:convert';
|
|
|
|
class LoanProvider extends ChangeNotifier {
|
|
Future<bool> addLoanRequest(Map<String, dynamic> body) async {
|
|
try {
|
|
Response response = await ApiManager.instance.post(URLs.addLoan, body: body);
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
// trafRequestDataModel = TrafRequestDataModel.fromJson(json.decode(response.body)["data"]);
|
|
return true;
|
|
}
|
|
return false;
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool isLoading = false;
|
|
|
|
LoanRequestModel? loanData;
|
|
|
|
Future<void> getLoanById(int id) async {
|
|
loanData = null;
|
|
isLoading = true;
|
|
notifyListeners();
|
|
|
|
try {
|
|
Response response = await ApiManager.instance.get(URLs.getLoanById + "?loanId=$id");
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
loanData = LoanRequestModel.fromJson(json.decode(response.body)["data"]);
|
|
}
|
|
// return data;
|
|
} catch (error) {
|
|
// return data;
|
|
}
|
|
isLoading = false;
|
|
notifyListeners();
|
|
}
|
|
}
|