Skip to content

Commit

Permalink
fix: ensure non-null text elements
Browse files Browse the repository at this point in the history
This is a review suggestion by sourcery-ai.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and adityastic committed Jan 5, 2025
1 parent a2cb4d3 commit 3f67490
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/bademagic_module/models/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ class Message {
throw Exception('Invalid JSON: "text" must be a list');
}

final textList = json['text'] as List;
if (textList.any((element) => element == null)) {
throw Exception('Invalid JSON: "text" list cannot contain null elements');
}

return Message(
text: List<String>.from(json['text']),
text: List<String>.from(textList),
flash: (json['flash'] as bool?) ?? false,
marquee: (json['marquee'] as bool?) ?? false,
speed: Speed.fromHex(
Expand Down

0 comments on commit 3f67490

Please sign in to comment.