fromMap static method

Poll? fromMap(
  1. Map<String, dynamic>? _map
)
override

Construct from Map.

Implementation

static Poll? fromMap(Map<String, dynamic>? _map) {
  if (_map == null) return null;
  var _ = _map["@type"];
  if (_ != CONSTRUCTOR) return null;
  var extra = _map['@extra'];
  var clientId = _map['@clientId'];
  var id = _map['id']! as int64;
  var question = _map['question']! as String;
  var options = List<PollOption>.from(
    (_map["options"] ?? []).map(
      (e) => PollOption.fromMap(e),
    ),
  );
  var total_voter_count = _map['total_voter_count']! as int;
  var recent_voter_ids = List<MessageSender>.from(
    (_map["recent_voter_ids"] ?? []).map(
      (e) => MessageSender.fromMap(e),
    ),
  );
  var is_anonymous = _map['is_anonymous']! as bool;
  var type = PollType.fromMap(_map['type'])!;
  var open_period = _map['open_period']! as int;
  var close_date = _map['close_date']! as int;
  var is_closed = _map['is_closed']! as bool;
  return Poll(
    extra: extra,
    clientId: clientId,
    id: id,
    question: question,
    options: options,
    total_voter_count: total_voter_count,
    recent_voter_ids: recent_voter_ids,
    is_anonymous: is_anonymous,
    type: type,
    open_period: open_period,
    close_date: close_date,
    is_closed: is_closed,
  );
}