From c2dedb14aceb90fb01c132d0918245d18e570c7f Mon Sep 17 00:00:00 2001 From: krawieck Date: Mon, 7 Sep 2020 21:57:43 +0200 Subject: [PATCH] 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 --- lib/pages/community.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pages/community.dart b/lib/pages/community.dart index cf7c5bc..48984dd 100644 --- a/lib/pages/community.dart +++ b/lib/pages/community.dart @@ -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])