
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
- Sites 30MB limit from GitHub
I’m deploying a site from github as Other type on the Hobby plan. It is actually a Flutter web app but it’s in a subdirectory with the root being an html landin...
- Function running in cloud but not locall...
Hi everyone, I have an appwrite function which is on python3.12 runtime. I have a library (hnswlib) which builds wheels during installation. This works on appwr...
- Permissions for bulk operation
Hi team, I have a question: “In the databases.createDocuments bulk API, can I set document-level permissions? If yes, how exactly should I include the permissio...
