Skip to content

Commit 81317ba

Browse files
committed
improve poll widget state
1 parent 72d733f commit 81317ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sample_app/lib/screens/user_feed/polls/show_poll/show_poll_widget.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ class ShowPollWidget extends StatefulWidget {
2020
State<ShowPollWidget> createState() => _ShowPollWidgetState();
2121
}
2222

23-
class _ShowPollWidgetState extends State<ShowPollWidget> {
23+
class _ShowPollWidgetState extends State<ShowPollWidget>
24+
with AutomaticKeepAliveClientMixin {
2425
StreamFeedsClient get client => locator<StreamFeedsClient>();
2526
late Activity activity;
2627

28+
@override
29+
bool get wantKeepAlive => true;
30+
2731
@override
2832
void initState() {
2933
super.initState();
@@ -55,12 +59,12 @@ class _ShowPollWidgetState extends State<ShowPollWidget> {
5559

5660
@override
5761
Widget build(BuildContext context) {
62+
super.build(context);
63+
5864
return StateNotifierBuilder(
5965
stateNotifier: activity.notifier,
6066
builder: (context, state, child) {
61-
final poll = state.poll;
62-
if (poll == null) return const SizedBox.shrink();
63-
67+
final poll = state.poll ?? widget.poll;
6468
return PollMessage(
6569
poll: poll,
6670
activity: activity,

0 commit comments

Comments
 (0)