parse static method

List<Message> parse(
  1. dynamic data
)

Because Mobile platforms returns data as list and desktop returns as map , so to unify the data

Implementation

static List<Message> parse(data) {
  if (data == null) return [];
  if (data is List) {
    return data.map((e) => Message.fromJson(e)).toList();
  } else if (data is Map<String, dynamic>) {
    return [Message.fromJson(data)];
  }
  return [];
}