From 3eda464e0329285ddd40d29958f5954f02b159b5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 22 Dec 2024 20:28:53 +0800 Subject: [PATCH] :bug: Fix search post did not triggered --- lib/screens/post/post_search.dart | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/screens/post/post_search.dart b/lib/screens/post/post_search.dart index 583228e..bcda095 100644 --- a/lib/screens/post/post_search.dart +++ b/lib/screens/post/post_search.dart @@ -99,11 +99,16 @@ class _PostSearchScreenState extends State { ], ).padding(horizontal: 24, vertical: 16), ).then((_) { - _posts.clear(); - _fetchPosts(); + _refreshPosts(); }); } + Future _refreshPosts() { + _postCount = null; + _posts.clear(); + return _fetchPosts(); + } + @override Widget build(BuildContext context) { const labelShadows = [ @@ -144,8 +149,7 @@ class _PostSearchScreenState extends State { setState(() => _posts[idx] = data); }, onDeleted: () { - _posts.clear(); - _fetchPosts(); + _refreshPosts(); }, ), onTap: () { @@ -176,10 +180,8 @@ class _PostSearchScreenState extends State { _searchTerm = value; }, onSubmitted: (value) { - setState(() => _posts.clear()); - _searchTerm = value; - _fetchPosts(); + _refreshPosts(); }, ), if (_lastTook != null)