that is what i am asking why should we use either one of them , and what if i use main instead of start
You must use start. Your code is injected into our server code which runs using main and you can only have one main function. See https://github.com/open-runtimes/open-runtimes/blob/801c6a833aec4ec72fc8562b5dffba2b3967ed6b/runtimes/dart-2.17/server.dart#L37
visited the link but did not find what is the actual use of start
await user_code.start(request, response);
In this code, user_code is the code that you write in your cloud function. So when your code is passed into appwrite's server, it looks for the start function in your code, and not main.
Another reason as Steven stated, is that there cannot be 2 main functions in one program. main is where the execution begins, and there can't be two starting points.
If you look through the code in the link he sent, you'll see that line 11 has a void main().
Hope that makes sense.
got your point, but there is still one doubt, is start is used for getting response and for making request and accessing environment variable?
right ?
yes that's correct!
you don't need to worry about the underlying code that runs your cloud function. If you have dependencies and environment variables, you can use them in your function, in the start().
For a detailed explanation on dependencies and more in regards to cloud functions, head to this link, and click on the Dart tab to see it's documentation.
Thanks man
No problem <:appwritecheers:892495536823861258>
as you suggest i have to use start, but in this link why not used start, any suggestion you would like to give and also which package should i use (dart_appwrite or appwrite)https://github.com/lohanidamodar/30daysofappwrite_email_sendgrid/blob/main/main.dart
I think the reason that this particular code uses main(), is because that's how the cloud functions were setup at the time.
If you notice, the code you sent was updated 2 years ago, which was way before Appwrite v1.x
yes i am aware of that
As a matter of fact, I looked at the code examples from 2 years ago, and cloud functions seem to have used main() instead of start()
To answer your question about which package to use:
If you're using appwrite in a Flutter application, use appwrite: https://pub.dev/packages/appwrite
If you're using appwrite in a Dart-only application, use dart_appwrite: https://pub.dev/packages/dart_appwrite
Since you're using the server sdk, which supports only Dart, use dart_appwrite
okay,
what are function variable and how to use them and also trigger
please make a new post for a different question. helps keep different questions in their own discussion
and let me know if you need any more help with the question for this post. if not, I'll mark it as solved ๐
ok you can marked as solved
[SOLVED] Difference between main() and start() in Dart Server SDK
Recommended threads
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- Appwrite (Dart SDK) (for package_info_pl...
Hi team! Many Flutter plugins now need package_info_plus 10.x and device_info_plus 13.x, but appwrite 25.4.0 still constrains package_info_plus: >=8.0.2 <10.0...
- Functions in cloud console not works
please advise as all of my runing functions on Appwrite console was working before , but now it give this error [Invalid `headers` param: Value must be a valid...