From b58f91bc84a84c773cbe6c70cd4fc6330fc1e987 Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Tue, 19 Oct 2021 19:29:26 +0200 Subject: [PATCH] make FullPostPage constructor private --- lib/pages/create_post.dart | 7 ++----- lib/pages/full_post/full_post.dart | 12 ++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/pages/create_post.dart b/lib/pages/create_post.dart index e5404b3..8b7a1e8 100644 --- a/lib/pages/create_post.dart +++ b/lib/pages/create_post.dart @@ -12,7 +12,6 @@ import '../hooks/stores.dart'; import '../l10n/l10n.dart'; import '../util/extensions/api.dart'; import '../util/extensions/spaced.dart'; -import '../util/goto.dart'; import '../util/pictrs.dart'; import '../widgets/editor.dart'; import '../widgets/markdown_mode_icon.dart'; @@ -39,10 +38,8 @@ class CreatePostFab extends HookWidget { ); if (postView != null) { - await goTo( - context, - (_) => FullPostPage.fromPostView(postView), - ); + await Navigator.of(context) + .push(FullPostPage.fromPostViewRoute(postView)); } }), child: const Icon(Icons.add), diff --git a/lib/pages/full_post/full_post.dart b/lib/pages/full_post/full_post.dart index ce8247f..34ae6b0 100644 --- a/lib/pages/full_post/full_post.dart +++ b/lib/pages/full_post/full_post.dart @@ -29,16 +29,16 @@ class FullPostPage extends StatelessWidget { final PostView? postView; final PostStore? postStore; - const FullPostPage({ + const FullPostPage._({ required int this.id, required String this.instanceHost, }) : postView = null, postStore = null; - const FullPostPage.fromPostView(PostView this.postView) + const FullPostPage._fromPostView(PostView this.postView) : id = null, instanceHost = null, postStore = null; - const FullPostPage.fromPostStore(PostStore this.postStore) + const FullPostPage._fromPostStore(PostStore this.postStore) : id = null, instanceHost = null, postView = null; @@ -67,7 +67,7 @@ class FullPostPage extends StatelessWidget { create: (context) => FullPostStore(instanceHost: instanceHost, postId: id) ..refresh(_tryGetJwt(context, instanceHost)), - child: FullPostPage( + child: FullPostPage._( id: id, instanceHost: instanceHost, ), @@ -78,14 +78,14 @@ class FullPostPage extends StatelessWidget { builder: (context) => Provider( create: (context) => FullPostStore.fromPostView(postView) ..refresh(_tryGetJwt(context, postView.instanceHost)), - child: FullPostPage.fromPostView(postView), + child: FullPostPage._fromPostView(postView), ), ); static Route fromPostStoreRoute(PostStore postStore) => MaterialPageRoute( builder: (context) => Provider( create: (context) => FullPostStore.fromPostStore(postStore) ..refresh(_tryGetJwt(context, postStore.postView.instanceHost)), - child: FullPostPage.fromPostStore(postStore)), + child: FullPostPage._fromPostStore(postStore)), ); }