Make 3 constructors for `CommunityPage` instead of 2

instead of single default constructor using name of the
community, there are now 2 where first takes community
name, and second which takes the id
This commit is contained in:
krawieck 2020-09-07 21:57:43 +02:00
parent f00c02b631
commit c2dedb14ac
1 changed files with 8 additions and 1 deletions

View File

@ -14,12 +14,19 @@ class CommunityPage extends HookWidget {
final CommunityView _community;
final String instanceUrl;
CommunityPage({@required String communityName, @required this.instanceUrl})
CommunityPage.fromName(
{@required String communityName, @required this.instanceUrl})
: assert(communityName != null),
assert(instanceUrl != null),
_fullCommunityFuture =
LemmyApi(instanceUrl).v1.getCommunity(name: communityName),
_community = null;
CommunityPage.fromId({@required int communityId, @required this.instanceUrl})
: assert(communityId != null),
assert(instanceUrl != null),
_fullCommunityFuture =
LemmyApi(instanceUrl).v1.getCommunity(id: communityId),
_community = null;
CommunityPage.fromCommunityView(this._community)
: instanceUrl = _community.actorId.split('/')[2],
_fullCommunityFuture = LemmyApi(_community.actorId.split('/')[2])