@@ -16,8 +16,10 @@ class NewListRecord extends State<ListRecord> {
1616 final apiURL = Uri .parse ('https://pcc.edu.pk/ws/list/hms_consumers.php' );
1717 var response = await http.get (apiURL);
1818 if (response.statusCode == 200 ) {
19- data = jsonDecode (response.body);
20- print (data);
19+ setState (() {
20+ data = jsonDecode (response.body);
21+ data.removeAt (0 );
22+ });
2123 } else {
2224 print ('fail' );
2325 print (response);
@@ -93,141 +95,60 @@ class NewListRecord extends State<ListRecord> {
9395 ),
9496 ],
9597 ),
96- Column (
97- children: data.length != 0
98- ? data.map ((e) {
98+ SingleChildScrollView (
99+ scrollDirection: Axis .horizontal,
100+ child: DataTable (
101+ columns: [
102+ DataColumn (
103+ label: Text ('First Name' ,
104+ style: TextStyle (
105+ fontFamily: 'Raleway' ,
106+ fontSize: 16 ,
107+ color: Colors .grey[600 ],
108+ ))),
109+ DataColumn (
110+ label: Text ('Last Name' ,
111+ style: TextStyle (
112+ fontFamily: 'Raleway' ,
113+ fontSize: 16 ,
114+ color: Colors .grey[600 ],
115+ ))),
116+ DataColumn (
117+ label: Text ('Gender' ,
118+ style: TextStyle (
119+ fontFamily: 'Raleway' ,
120+ fontSize: 16 ,
121+ color: Colors .grey[600 ],
122+ ))),
123+ DataColumn (
124+ label: Text ('Email' ,
125+ style: TextStyle (
126+ fontFamily: 'Raleway' ,
127+ fontSize: 16 ,
128+ color: Colors .grey[600 ],
129+ ))),
130+ DataColumn (
131+ label: Text ('Phone Number' ,
132+ style: TextStyle (
133+ fontFamily: 'Raleway' ,
134+ fontSize: 16 ,
135+ color: Colors .grey[600 ],
136+ ))),
137+ ],
138+ rows: data.map ((e) {
99139 if (e['id' ] != 1 ) {
100- Center (
101- child: Card (
102- margin: EdgeInsets .only (top: 30 , bottom: 30 ),
103- child: Container (
104- width: 350 ,
105- padding: EdgeInsets .only (top: 40 , bottom: 20 ),
106- child: Column (
107- children: [
108- // first name
109- Container (
110- padding: EdgeInsets .only (
111- top: 40 , bottom: 10 , left: 30 ),
112- child: Row (children: [
113- Container (
114- padding:
115- EdgeInsets .only (right: 30 ),
116- child: Text (
117- 'First Name' ,
118- style: TextStyle (
119- fontFamily: 'Raleway' ,
120- fontSize: 14 ,
121- color: Colors .grey[600 ],
122- ),
123- ),
124- ),
125- Container (
126- width: 200 ,
127- child: Text (e['firstName' ]),
128- ),
129- ])),
130- // last name
131- Container (
132- padding: EdgeInsets .only (
133- top: 40 , bottom: 10 , left: 30 ),
134- child: Row (children: [
135- Container (
136- padding:
137- EdgeInsets .only (right: 30 ),
138- child: Text (
139- 'Last Name' ,
140- style: TextStyle (
141- fontFamily: 'Raleway' ,
142- fontSize: 14 ,
143- color: Colors .grey[600 ],
144- ),
145- ),
146- ),
147- Container (
148- width: 200 ,
149- child: Text (e['lastName' ]),
150- ),
151- ])),
152- // gender
153- Container (
154- padding: EdgeInsets .only (
155- top: 40 , bottom: 10 , left: 30 ),
156- child: Row (children: [
157- Container (
158- padding:
159- EdgeInsets .only (right: 30 ),
160- child: Text (
161- 'Gender' ,
162- style: TextStyle (
163- fontFamily: 'Raleway' ,
164- fontSize: 14 ,
165- color: Colors .grey[600 ],
166- ),
167- ),
168- ),
169- Container (
170- width: 200 ,
171- child: Text (e['gender' ]),
172- ),
173- ])),
174- // email
175- Container (
176- padding: EdgeInsets .only (
177- top: 40 , bottom: 10 , left: 30 ),
178- child: Row (children: [
179- Container (
180- padding:
181- EdgeInsets .only (right: 30 ),
182- child: Text (
183- 'Email' ,
184- style: TextStyle (
185- fontFamily: 'Raleway' ,
186- fontSize: 14 ,
187- color: Colors .grey[600 ],
188- ),
189- ),
190- ),
191- Container (
192- width: 200 ,
193- child: Text (e['email' ]),
194- ),
195- ])),
196- // phone number
197- Container (
198- padding: EdgeInsets .only (
199- top: 40 , bottom: 10 , left: 30 ),
200- child: Row (children: [
201- Container (
202- padding:
203- EdgeInsets .only (right: 30 ),
204- child: Text (
205- 'Number' ,
206- style: TextStyle (
207- fontFamily: 'Raleway' ,
208- fontSize: 14 ,
209- color: Colors .grey[600 ],
210- ),
211- ),
212- ),
213- Container (
214- width: 200 ,
215- child: Text (e['phone' ]),
216- ),
217- ])),
218- ],
219- ),
220- ),
221- ),
222- );
140+ print (e['id' ]);
141+ return DataRow (cells: [
142+ DataCell (Text (e['firstName' ])),
143+ DataCell (Text (e['lastName' ])),
144+ DataCell (Text (e['gender' ])),
145+ DataCell (Text (e['email' ])),
146+ DataCell (Text (e['phone' ])),
147+ ]);
148+ } else {
149+ print ('hello' );
223150 }
224- }).toList ()
225- : [
226- Container (
227- child: Text ('Hello' ),
228- )
229- ],
230- )
151+ }).toList ())),
231152 ],
232153 ),
233154 ),
0 commit comments