-
Notifications
You must be signed in to change notification settings - Fork 0
/
Explore.dart
114 lines (100 loc) · 3.86 KB
/
Explore.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'dart:io' as IO;
import 'dart:async';
import 'dart:convert';
class Explore extends StatefulWidget {
@override
_ExploreState createState() => _ExploreState();
}
class _ExploreState extends State<Explore> {
List<Person> people = [];
IO.File imagefile;
var _getpeople;
Future<List<Person>> _getPeople() async {
var response = await http.get('http://192.168.18.13:5000/explore');
var data = json.decode(response.body);
int count = 0;
for (var x in data){
var decodedBytes = base64Decode(x['img']);
Person person = Person(x['name'],x['Gender'],x['height'], x['Area'],x['RepNumber'],decodedBytes);
people.add(person);
count = count+1;
}
print(people.length);
return people;
}
@override
void initState(){
_getpeople = _getPeople();
super.initState();
}
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Colors.white,
size: 40,
),
onPressed: (){
Navigator.pop(context);
},
),
backgroundColor: Color(0xFF532e7a),
title: Text('Explore Repository',style: TextStyle(fontFamily: 'Merriweather',color: Colors.white),textAlign: TextAlign.center,),
),
body: Container(
child: FutureBuilder(
future: _getpeople,
builder: (BuildContext context,AsyncSnapshot snapshot) {
if(snapshot.hasData){
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index){
return Column(
children: [
Image.memory(people[index].imageFile),
Text('Name: '+people[index].PersonName,style: TextStyle(fontFamily: 'Merriweather',fontSize: 15),),
Text('Gender: '+people[index].Gender,style: TextStyle(fontFamily: 'Merriweather',fontSize: 15),),
Text('Height: '+people[index].Height,style: TextStyle(fontFamily: 'Merriweather',fontSize: 15),textAlign: TextAlign.start,),
Text('Last seen in: '+people[index].LastSeenArea,style: TextStyle(fontFamily: 'Merriweather',fontSize: 15),textAlign: TextAlign.start,),
Text('Reporter\'s Number: '+people[index].ReporterNumber,style: TextStyle(fontFamily: 'Merriweather',fontSize: 15),textAlign: TextAlign.start,),
Divider(
color: Color(0xFF532e7a),
),
],
);
}
);
}
else{
return Center(
child: Container(
child: CircularProgressIndicator(strokeWidth: 10.0,valueColor: new AlwaysStoppedAnimation<Color>(Color(0xFF532e7a))),
height: 100,
width: 100,
padding: EdgeInsets.only(top: 16.0),
),
);
}
},),
),
),
);
}
}
class Person {
String PersonName;
String Gender;
String Height;
String LastSeenArea;
String ReporterNumber;
Uint8List imageFile;
Person(this.PersonName, this.Gender, this.Height, this.LastSeenArea, this.ReporterNumber,this.imageFile);
}