Skip to content

Instantly share code, notes, and snippets.

@vasilich6107
Created January 13, 2020 21:13
Show Gist options
  • Save vasilich6107/455a5358bd8a9efbb4d53e1bf72526b8 to your computer and use it in GitHub Desktop.
Save vasilich6107/455a5358bd8a9efbb4d53e1bf72526b8 to your computer and use it in GitHub Desktop.
Query(
options: QueryOptions(
documentNode: CompaniesDataQuery().document,
),
builder: (
QueryResult result, {
Future<QueryResult> Function() refetch,
FetchMore fetchMore,
}) {
if (result.hasException) {
return Text(result.exception.toString());
}
if (result.loading) {
return const Center(
child: CircularProgressIndicator(),
);
}
final allCompanies = CompaniesData.fromJson(result.data).allCompanies;
return ListView.builder(
itemBuilder: (_, index) {
return ListTile(
leading: Icon(Icons.card_travel),
title: Text(allCompanies[index].name),
subtitle: Text(allCompanies[index].industry),
);
},
itemCount: allCompanies.length,
);
},
)
@chodex-xyz
Copy link

небольшая опечатка в примере

final allCompanies = CompaniesData.fromJson(result.data).allCompanies;
# надо
final allCompanies = CompaniesData$Query.fromJson(result.data).allCompanies;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment