Skip to content

Commit

Permalink
feat: disable flash and marquee if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd committed Jan 4, 2025
1 parent 4ba86d0 commit 21c0adf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/bademagic_module/models/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class Message {

// Convert JSON to Message object
factory Message.fromJson(Map<String, dynamic> json) {
if (json is! Map) {
throw Exception('Invalid JSON: "messages" must contain a map');
}

if (!json.containsKey('text')) {
throw Exception('Invalid JSON: Message missing "text" key');
}
Expand All @@ -49,8 +45,8 @@ class Message {

return Message(
text: List<String>.from(json['text']),
flash: json['flash'] as bool,
marquee: json['marquee'] as bool,
flash: (json['flash'] as bool?) ?? false,
marquee: (json['marquee'] as bool?) ?? false,
speed: Speed.fromHex(
json['speed'] as String), // Using helper method for safety
mode: Mode.fromHex(
Expand Down

0 comments on commit 21c0adf

Please sign in to comment.