Skip to content

Commit d759b34

Browse files
committed
feat: shimmer in postbox and fetch profile image
1 parent f3324b7 commit d759b34

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

lib/widgets/post_box.dart

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import 'package:cached_network_image/cached_network_image.dart';
12
import 'package:figma_squircle/figma_squircle.dart';
23
import 'package:fistagram/custom_icons_icons.dart';
34
import 'package:fistagram/utils/colors.dart';
45
import 'package:flutter/material.dart';
6+
import 'package:shimmer/shimmer.dart';
57

68
class PostBox extends StatefulWidget {
79
final String userId;
810
final likes, numberOfComments;
911
final String imagePath;
12+
final String profileImage;
1013
const PostBox({
1114
Key? key,
1215
required this.userId,
16+
required this.profileImage,
1317
required this.likes,
1418
required this.numberOfComments,
1519
required this.imagePath,
@@ -40,7 +44,7 @@ class _PostBoxState extends State<PostBox> {
4044
),
4145
CircleAvatar(
4246
radius: 13,
43-
child: Image.asset("assets/img/profile_pic.png"),
47+
backgroundImage: NetworkImage(widget.profileImage),
4448
),
4549
const Padding(
4650
padding: EdgeInsets.only(
@@ -75,10 +79,22 @@ class _PostBoxState extends State<PostBox> {
7579
cornerRadius: 12,
7680
cornerSmoothing: 1,
7781
),
78-
child: Container(
79-
height: MediaQuery.of(context).size.height * 0.45,
80-
width: MediaQuery.of(context).size.width * 0.9,
81-
child: Image.asset(widget.imagePath, fit: BoxFit.cover)),
82+
child: SizedBox(
83+
height: MediaQuery.of(context).size.height * 0.45,
84+
width: MediaQuery.of(context).size.width * 0.9,
85+
child: CachedNetworkImage(
86+
imageUrl: widget.imagePath,
87+
placeholder: (context, url) {
88+
return Shimmer.fromColors(
89+
baseColor: Colors.grey[300]!,
90+
highlightColor: Colors.grey[100]!,
91+
child: Container(
92+
color: Colors.grey[300],
93+
));
94+
},
95+
fit: BoxFit.cover,
96+
),
97+
),
8298
),
8399
//-----------------------Footer section----------------------
84100
Container(
@@ -127,7 +143,7 @@ class _PostBoxState extends State<PostBox> {
127143
style: const TextStyle(
128144
fontSize: 16, fontWeight: FontWeight.w300))
129145
]),
130-
Spacer(),
146+
const Spacer(),
131147
SizedBox(
132148
width: 32,
133149
child: IconButton(

0 commit comments

Comments
 (0)