Skip to content

Commit f402438

Browse files
committed
feat: displaying Age and Occupation fields
1 parent 2b77fce commit f402438

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

client/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MyApp extends StatelessWidget {
3434
child: CacheProvider(
3535
child: MaterialApp(
3636
debugShowCheckedModeBanner: false,
37-
title: 'Flutter Demo',
37+
title: 'Flutter GraphQL Demo',
3838
theme: ThemeData(
3939
primarySwatch: Colors.blueGrey,
4040
visualDensity: VisualDensity.adaptivePlatformDensity,

client/lib/views/users_page.dart

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:graphql_flutter/graphql_flutter.dart';
33

44
class UsersPage extends StatefulWidget {
55
const UsersPage({Key? key}) : super(key: key);
6-
6+
77
@override
88
State<UsersPage> createState() => _UsersPageState();
99
}
@@ -14,7 +14,6 @@ class _UsersPageState extends State<UsersPage> {
1414
query{
1515
users{
1616
name
17-
id
1817
profession
1918
age
2019
}
@@ -32,8 +31,8 @@ class _UsersPageState extends State<UsersPage> {
3231
users = result.data!["users"];
3332

3433
return (users.isNotEmpty) ? ListView.builder(
35-
itemCount: users.length,
36-
itemBuilder: (context, index) {
34+
itemCount: users.length,
35+
itemBuilder: (context, index) {
3736
final user = users[index];
3837

3938
return Stack(
@@ -71,6 +70,26 @@ class _UsersPageState extends State<UsersPage> {
7170
),
7271
],
7372
),
73+
Row(
74+
children: [
75+
Padding(
76+
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
77+
child: Text(
78+
'Occupation: ${user["profession"] ?? 'N/A'}'
79+
),
80+
),
81+
],
82+
),
83+
Row(
84+
children: [
85+
Padding(
86+
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
87+
child: Text(
88+
'Age: ${user["age"] ?? 'N/A'}'
89+
),
90+
),
91+
],
92+
)
7493
],
7594
),
7695
),
@@ -82,6 +101,7 @@ class _UsersPageState extends State<UsersPage> {
82101
) : const Center(
83102
child: Text("No users found"),
84103
);
104+
85105
},
86106
);
87107
}

0 commit comments

Comments
 (0)