Rank 3: Container
that is what i am asking why should we use either one of them , and what if i use main instead of start
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
that is what i am asking why should we use either one of them , and what if i use main instead of start
Admin
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
Rank 3: Container
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.
Rank 3: Container
got your point, but there is still one doubt, is start is used for getting response and for making request and accessing environment variable?
Rank 3: Container
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.
Rank 3: Container
Thanks man
No problem 
Rank 3: Container
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
Rank 3: Container
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
Rank 3: Container
okay,
Rank 3: Container
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 🙂
Rank 3: Container
ok you can marked as solved
[SOLVED] Difference between main() and start() in Dart Server SDK