fromJson static method
Parse a button entry from the bridge payload, returning null when the entry is
malformed (missing/non-string/empty label). A factory constructor can't return
null, so this is a regular static method — callers filter the nulls out instead of
catching a runtime cast error. Native already drops empty-label entries before
sending; this is a defensive net for unexpected wire shapes.
Implementation
static FlareLaneNotificationButton? fromJson(Map json) {
final label = json['label'];
if (label is! String || label.isEmpty) return null;
// Defensively check `link` shape too: a non-String value would crash the
// `as String?` cast at runtime. Drop unexpected shapes silently — better
// to lose the link than to take the host app down.
final link = json['link'];
return FlareLaneNotificationButton(
label: label,
link: link is String ? link : null,
);
}