refractor: update code and project to use latest Appwrite SDK #23
refractor: update code and project to use latest Appwrite SDK #23
Conversation
lib/constants.dart
Outdated
@@ -2,4 +2,5 @@ class AppConstsnts { | |||
static const String endPoint = "https://demo.appwrite.io/v1"; | |||
static const String project = "606d5bc9de604"; | |||
static const String collection = "606d5bd9626ae"; | |||
static const String databaseID = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "default" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know the database ID for tutorial. Lemme apply this in a few
load_questions.dart
Outdated
Database db = Database(client); | ||
final collectionId = 'quiz_questions'; | ||
final res = await db.createCollection( | ||
Databases db = Databases(client, databaseId: 'unique()'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this one should be default also to match up with the other value after created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this commit today morning after I read the discussion @stnguyen90 had with @2002Bishwajeet concerning how to create the databases with Serverside SDK. You have to provide a "unique()" parameter first and then provide the actual id to be used. If I'm not wrong since the constructor has to be there 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change it to default
instead of Quizy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting unique()
and then calling db.create(name: 'Quizy');
would create a Database with a unique auto generated ID, but you can also use your own custom ID to create the Database with that ID.
I agree with @brandonroberts suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I'll fix that. Thanks for the clarification. Seems I got confused as you explained.
load_questions.dart
Outdated
final res = await db.createCollection( | ||
Databases db = Databases(client, databaseId: 'unique()'); | ||
|
||
db.create(name: 'Quizy'); // added funky name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be using await
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. I'll fix this.
Co-authored-by: Brandon <robertsbt@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lib/constants.dart
Outdated
@@ -1,5 +1,6 @@ | |||
class AppConstsnts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this too. Ofc this doesn't make sense.😹
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looks like you need to merge the latest changes from upstream
. A PR has been already made, 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 fixed after some few issues
lib/quiz.dart
Outdated
@@ -65,16 +73,16 @@ class _QuizPageState extends State<QuizPage> { | |||
itemCount: questions!.length, | |||
itemBuilder: (context, index) { | |||
final question = questions![index]; | |||
return Container( | |||
return SizedBox( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove SizedBox
also, I don't think we should be needing that here.
@@ -107,13 +117,13 @@ class _QuizPageState extends State<QuizPage> { | |||
}, | |||
), | |||
) | |||
: Container( | |||
: const SizedBox( | |||
child: Text("Some error! Check console"), | |||
), | |||
/* A language that doesn't affect the way you think about programming is not worth knowing. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's outdated now. You can remove these comments too😆
lib/quiz.dart
Outdated
@@ -107,13 +117,13 @@ class _QuizPageState extends State<QuizPage> { | |||
}, | |||
), | |||
) | |||
: Container( | |||
: const SizedBox( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, unnecssary SizedBox
here
LGTM! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Saw the project was last updated in May and is part of the Awesome Appwrite Project. Decided to help migrate and update it. I refractored some code and made some changes.
Changes Made