1
+ import 'package:blogapp/Model/profileModel.dart' ;
1
2
import 'package:blogapp/NetworkHandler.dart' ;
2
3
import 'package:flutter/material.dart' ;
3
4
@@ -9,6 +10,25 @@ class MainProfile extends StatefulWidget {
9
10
}
10
11
11
12
class _MainProfileState extends State <MainProfile > {
13
+ bool circular = true ;
14
+ NetworkHandler networkHandler = NetworkHandler ();
15
+ ProfileModel profileModel = ProfileModel ();
16
+ @override
17
+ void initState () {
18
+ // TODO: implement initState
19
+ super .initState ();
20
+
21
+ fetchData ();
22
+ }
23
+
24
+ void fetchData () async {
25
+ var response = await networkHandler.get ("/profile/getData" );
26
+ setState (() {
27
+ profileModel = ProfileModel .fromJson (response["data" ]);
28
+ circular = false ;
29
+ });
30
+ }
31
+
12
32
@override
13
33
Widget build (BuildContext context) {
14
34
return Scaffold (
@@ -28,20 +48,23 @@ class _MainProfileState extends State<MainProfile> {
28
48
),
29
49
],
30
50
),
31
- body: ListView (
32
- children: < Widget > [
33
- head (),
34
- Divider (
35
- thickness: 0.8 ,
36
- ),
37
- otherDetails ("About" ,
38
- " I am a balram rathore a fullstack developer also a web and app developer" ),
39
- otherDetails ("Name" , "Balram Rathore" ),
40
- Divider (
41
- thickness: 0.8 ,
42
- ),
43
- ],
44
- ),
51
+ body: circular
52
+ ? Center (child: CircularProgressIndicator ())
53
+ : ListView (
54
+ children: < Widget > [
55
+ head (),
56
+ Divider (
57
+ thickness: 0.8 ,
58
+ ),
59
+ otherDetails ("About" , profileModel.about),
60
+ otherDetails ("Name" , profileModel.name),
61
+ otherDetails ("Profession" , profileModel.profession),
62
+ otherDetails ("DOB" , profileModel.DOB ),
63
+ Divider (
64
+ thickness: 0.8 ,
65
+ ),
66
+ ],
67
+ ),
45
68
);
46
69
}
47
70
@@ -54,17 +77,17 @@ class _MainProfileState extends State<MainProfile> {
54
77
Center (
55
78
child: CircleAvatar (
56
79
radius: 50 ,
57
- backgroundImage: NetworkHandler ().getImage ("devStack06" ),
80
+ backgroundImage: NetworkHandler ().getImage (profileModel.username ),
58
81
),
59
82
),
60
83
Text (
61
- "DevStack06" ,
84
+ profileModel.username ,
62
85
style: TextStyle (fontSize: 18 , fontWeight: FontWeight .bold),
63
86
),
64
87
SizedBox (
65
88
height: 10 ,
66
89
),
67
- Text ("App Developer || Full Stack Developer, App and Web Developer" )
90
+ Text (profileModel.titleline )
68
91
],
69
92
),
70
93
);
0 commit comments