From 90b2deb4a09ae4d135c4391e8a45f9885497a273 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Tue, 8 Sep 2020 21:08:37 +0200 Subject: [PATCH] added from UserView constructor --- lib/widgets/user_profile.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/widgets/user_profile.dart b/lib/widgets/user_profile.dart index 6f0f714..ee5970f 100644 --- a/lib/widgets/user_profile.dart +++ b/lib/widgets/user_profile.dart @@ -10,18 +10,21 @@ import '../util/text_color.dart'; import 'badge.dart'; class UserProfile extends HookWidget { - final int userId; final Future _userView; final String instanceUrl; // TODO: add `.fromUser` constructor - UserProfile({@required this.userId, @required this.instanceUrl}) + UserProfile({@required int userId, @required this.instanceUrl}) : _userView = LemmyApi(instanceUrl) .v1 .getUserDetails( userId: userId, savedOnly: true, sort: SortType.active) .then((res) => res.user); + UserProfile.fromUserView(UserView userView) + : _userView = Future.value(userView), + instanceUrl = userView.actorId.split('/')[2]; + @override Widget build(BuildContext context) { var theme = Theme.of(context);