Here is the code I have tried
class AppwriteServices { Databases databases = Databases(client);
Future readBooks() async { final results = databases.listDocuments( databaseId: '647b2d9c3517092fd026', collectionId: '647b2dac72f880f4386d');
results.then((value) {
print(value.toMap());
}).catchError((error) {
print(error);
});
} }
##############
class HomeScreen extends StatelessWidget { const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: FutureBuilder(
future: AppwriteServices().readBooks(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
List records = snapshot.data['documents'];
return ListView.builder(
itemCount: records.length,
itemBuilder: (context, int index) {
return Card(
child: ListTile(
title: Text(records[index]['firstname']),
),
);
},
);
} else {
return Center(child: CircularProgressIndicator());
}
},
),
));
}
}
your function never returned any data so it can't be used in your widget tree.
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
Recommended threads
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...
- Does 1.9.0 Self Hosted have MongoDB Atla...
I have been playing with the new 1.9.0 update and I am really excited for the MongoDB support. I wanted to ask though if at the current time Appwrite supports b...
- {"code": 1008, "message": "Invalid Origi...
Nothing has changed in my application or console settings so I'm curious as to what I need to do to fix this. I already have the client registered so I'm not en...