PlurkWithUser.fromJson constructor

PlurkWithUser.fromJson(
  1. Map<String, dynamic> jsonObj
)

Implementation

PlurkWithUser.fromJson(Map<String, dynamic> jsonObj) {
  // Hopefully Map<String, PlurkUser> will be treated as Map<String, dynamic>
  Map<String, dynamic>? users = jsonObj['plurk_users'];
  plurkUsers = Map<int, User>();

  if (users != null) {
    users.forEach((key, value) {
      int? keyInt = int.tryParse(key);
      if (keyInt != null) {
        plurkUsers![keyInt] = User.fromJson(value);
      }
    });
  }

  if (jsonObj['plurk'] != null) {
    plurk = Plurk.fromJson(jsonObj['plurk']);
  }

  if (jsonObj['user'] != null) {
    user = User.fromJson(jsonObj['user']);
  }

  errorText = jsonObj['error_text'];
  successText = jsonObj['success_text'];
}