request<T> method
Future<GetResult<T>>
request<
T>({ - T? as,
- required String path,
- required GetMethod method,
- bool encrypted = false,
- bool inIsolate = true,
- List<GetFile>? files,
- Map<String, dynamic> query = const {},
- Map<String, dynamic> body = const {},
})
Implementation
Future<GetResult<T>> request<T>({
T? as,
required String path,
required GetMethod method,
bool encrypted = false,
bool inIsolate = true,
List<GetFile>? files,
Map<String, dynamic> query = const {},
Map<String, dynamic> body = const {},
}) async =>
scheduleTask(() async {
try {
if (encrypted) {
await Future.forEach(
query.keys,
(dynamic key) async =>
query[key] = await query[key]?.toString().encrypted,
);
await Future.forEach(
body.keys,
(dynamic key) async =>
body[key] = await body[key]?.toString().encrypted,
);
}
var parcel = GetRequestParcel<T, GetResult<T>>(
id: id,
address: await address,
path: path.pre(this.path, between: "/"),
method: method,
result: GetResult<T>(),
builder: as,
authToken: await authToken,
files: files,
query: query,
body: body,
);
return inIsolate && isolate != null
? isolate!.httpRequest(parcel)
: _parcelRequest(parcel);
} catch (e) {
return GetResult<T>.error(e.toString());
}
});