import 'package:flutter/widgets.dart'; /// WebSocket message /// /// @author Pierre Hubert class WsMessage { final String id; final String title; final dynamic data; const WsMessage({ @required this.id, @required this.title, @required this.data, }) : assert(id != null), assert(title != null); /// Construct a message from a JSON document (messages coming from the server) static WsMessage fromJSON(final Map m) { return WsMessage(id: m["id"], title: m["title"], data: m["data"]); } bool get hasId => this.id != null && this.id.isNotEmpty; }