Created
August 21, 2022 11:40
-
-
Save nbnD/7ccd65c9b2beb4c051d90fbc10e6de17 to your computer and use it in GitHub Desktop.
GraphQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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