Skip to content

Commit

Permalink
fix: ensure non-null messages
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 bcc9513 commit a2cb4d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/bademagic_module/models/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Data {

var messagesFromJson = json['messages'] as List;

if (messagesFromJson.any((message) => message == null)) {
throw Exception('Invalid JSON: "messages" list contains null values');
}

List<Message> messageList =
messagesFromJson.map((message) => Message.fromJson(message)).toList();

Expand Down

0 comments on commit a2cb4d3

Please sign in to comment.