Web service requests
The Android Apps Panel SDK provides easy way to communicate with web services.
Sample
Future<List<Model>?> getListOfItems() async {
final response = await AppsPanel.request(
action: "/path",
method: AppsPanelMethod.get,
sendUserToken: true,
);
if (response is RequestSuccessArray) {
return List.castFrom(req.data).map((e) => Model.fromJson(e)).toList();
} else if (response is RequestError) {
log("ERROR : ${response.message}, ${response.statusCode}, ${response.data}");
return null;
} else {
log("ERROR : ${response.runtimeType}");
}
}
Possible returned types :
RequestSuccessArray
: When the api request returns an object list as result
RequestSuccessObject
: When the api request returns an object as result
RequestSuccessEmpty
: When the api request return san empty body result
RequestError
: When the api request returns an error
Android details
https://appspanel.readme.io/docs/web-services
iOS details
Updated over 1 year ago