Hey, currently I dont seem to be able to find a way to give req and res in Future<void> start(final req, final res) a type which is pretty annoying. Are there any types for req and res I can use?`Something like AppwriteRequest or AppwriteResponse
We've had discussions about exposing the types. For now, maybe you can copy and paste this and cast the variables in your function body.
https://github.com/open-runtimes/open-runtimes/blob/main/runtimes/dart-2.17/function_types.dart
Casting doesnt work, 'im getting type 'Response' is not a subtype of type 'AppwriteResponse' in type cast'
class AppwriteRequest {
final Map<String, dynamic> variables;
final Map<String, dynamic> headers;
final String payload;
AppwriteRequest({
this.variables = const {},
this.headers = const {},
this.payload = '',
});
}
class AppwriteResponse {
int _status = 200;
dynamic _text;
int get status => _status;
dynamic get body => _text;
AppwriteResponse send(String? text, {int status = 200}) {
_text = text;
_status = status;
return this;
}
AppwriteResponse json(Map<String, dynamic> json, {int status = 200}) {
_text = json;
_status = status;
return this;
}
}
Womp. It still might be possible with a lot of hacking...
Yep, got it to work with this fancy hacky method:
T? castOrNull<T>(dynamic x) => x is T ? x : null;
AppwriteRequest? req = castOrNull<AppwriteRequest>(requ);
AppwriteResponse? res = castOrNull<AppwriteResponse>(resp);
Nvm, doesnt work :/
😕 ya...it might not be worth it to try and do that at the moment
Recommended threads
- How Can I Create landing page in appwrit...
I created function called invoice URL https://app.getrestt.com/v1/functions/invoice/executions?id=test-76f948fe83c43422561fe096c0674a1bd3ff0702cdfcf2444293ab31...
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...