Skip to content

Commit

Permalink
Merge pull request #141 from letsintegreat/issue-140-profile-pic
Browse files Browse the repository at this point in the history
Add a null check on profile pic
  • Loading branch information
Samuel Rosado authored Dec 23, 2022
2 parents 815556c + 9f5bac7 commit c4ba996
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file added assets/default_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion lib/src/pages/home/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class _UserProfileState extends ConsumerState<UserProfile> {
late Future<List<Issue>?> getUpvoteList;
late Future<List<Issue>?> getSavedList;

ImageProvider<Object> getProfilePicture() {
if (currentUser!.pfpLink == null) {
return AssetImage("assets/default_profile.png");
} else {
return NetworkImage(currentUser!.pfpLink!);
}
}

Future<List<Issue>?> getIssueList(List<int>? idList) async {
List<Issue>? issueList = null;
try {
Expand Down Expand Up @@ -235,7 +243,7 @@ class _UserProfileState extends ConsumerState<UserProfile> {
decoration: BoxDecoration(
color: Color(0xFFDC4654),
image: DecorationImage(
image: NetworkImage(currentUser!.pfpLink!),
image: getProfilePicture(),
fit: BoxFit.cover,
),
boxShadow: [BoxShadow(blurRadius: 7.0, color: Colors.black)],
Expand Down

0 comments on commit c4ba996

Please sign in to comment.