Skip to content

Commit 9938b27

Browse files
committed
api: Give defaults to question/options on PollWidgetExtraData
1 parent 819a44a commit 9938b27

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/api/model/submessage.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ class PollWidgetData extends WidgetData {
116116
/// As in [PollWidgetData.extraData].
117117
@JsonSerializable(fieldRename: FieldRename.snake)
118118
class PollWidgetExtraData {
119+
// The [question] and [options] fields seem to be always present.
120+
// But both web and zulip-mobile accept them as optional, with default values:
121+
// https://github.com/zulip/zulip-flutter/pull/823#discussion_r1697656896
122+
// https://github.com/zulip/zulip/blob/40f59a05c55e0e4f26ca87d2bca646770e94bff0/web/src/poll_widget.ts#L29
123+
// And the server doesn't really enforce any structure on submessage data.
124+
// So match the web and zulip-mobile behavior.
125+
@JsonKey(defaultValue: "")
119126
final String question;
127+
@JsonKey(defaultValue: [])
120128
final List<String> options;
121129

122130
const PollWidgetExtraData({required this.question, required this.options});

lib/api/model/submessage.g.dart

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)