postData<T> method
Future<T>
postData<T>({
- required String path,
- required T builder(
- dynamic data
- Options? options,
- FormData? formData,
Implementation
Future<T> postData<T>({
required String path,
required T Function(dynamic data) builder,
Options? options,
FormData? formData,
}) async {
try {
var reponse =
await dio.post(path, options: options ?? _options, data: formData);
switch (reponse.statusCode) {
case 200:
// var data = json.decode(reponse.data);
return builder(reponse.data);
case 401:
throw const APIError.invalidApiKey();
case 404:
throw const APIError.notFound();
default:
throw const APIError.unknown();
}
} on SocketException catch (_) {
throw const APIError.noInternetConnection();
}
}