Skip to content

Instantly share code, notes, and snippets.

@nbnD
Created August 21, 2022 11:40
Show Gist options
  • Save nbnD/7ccd65c9b2beb4c051d90fbc10e6de17 to your computer and use it in GitHub Desktop.
Save nbnD/7ccd65c9b2beb4c051d90fbc10e6de17 to your computer and use it in GitHub Desktop.
GraphQL
Query(
options: QueryOptions(
document: gql(query),
variables: const <String, dynamic>{"code": "AF"}),
builder: (result, {fetchMore, refetch}) {
if (result.isLoading) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (result.data == null) {
return const Center(
child: Text("Data Not Found!!!"),
);
}
return ListView.builder(
itemCount: result.data!['continent']['countries'].length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
result.data!['continent']['countries'][index]["name"],
),
subtitle: Text(
result.data!['continent']['countries'][index]["code"]),
);
});
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment