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
- API key without database.read/write
I had some issues with my previous API key and I deleted it then I wanted to create a new one and discovered the database checkbook has no database.read/write j...
- dynamic key missing scopes for database ...
Here are the scopes listed, I get permission errors for reading row and document. Appears to be missing since last time i checked. Database 6 Scopes policies....
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...