Skip to content

Commit 867c963

Browse files
committed
profile data fetch work completed
1 parent e9adc23 commit 867c963

File tree

5 files changed

+375
-17
lines changed

5 files changed

+375
-17
lines changed

lib/Model/profileModel.dart

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
3+
part 'profileModel.g.dart';
4+
5+
@JsonSerializable()
6+
class ProfileModel {
7+
String name;
8+
String username;
9+
String profession;
10+
String DOB;
11+
String titleline;
12+
String about;
13+
ProfileModel(
14+
{this.DOB,
15+
this.about,
16+
this.name,
17+
this.profession,
18+
this.titleline,
19+
this.username});
20+
21+
factory ProfileModel.fromJson(Map<String, dynamic> json) =>
22+
_$ProfileModelFromJson(json);
23+
Map<String, dynamic> toJson() => _$ProfileModelToJson(this);
24+
}

lib/Model/profileModel.g.dart

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Profile/MainProfile.dart

+40-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:blogapp/Model/profileModel.dart';
12
import 'package:blogapp/NetworkHandler.dart';
23
import 'package:flutter/material.dart';
34

@@ -9,6 +10,25 @@ class MainProfile extends StatefulWidget {
910
}
1011

1112
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+
1232
@override
1333
Widget build(BuildContext context) {
1434
return Scaffold(
@@ -28,20 +48,23 @@ class _MainProfileState extends State<MainProfile> {
2848
),
2949
],
3050
),
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+
),
4568
);
4669
}
4770

@@ -54,17 +77,17 @@ class _MainProfileState extends State<MainProfile> {
5477
Center(
5578
child: CircleAvatar(
5679
radius: 50,
57-
backgroundImage: NetworkHandler().getImage("devStack06"),
80+
backgroundImage: NetworkHandler().getImage(profileModel.username),
5881
),
5982
),
6083
Text(
61-
"DevStack06",
84+
profileModel.username,
6285
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
6386
),
6487
SizedBox(
6588
height: 10,
6689
),
67-
Text("App Developer || Full Stack Developer, App and Web Developer")
90+
Text(profileModel.titleline)
6891
],
6992
),
7093
);

0 commit comments

Comments
 (0)