ActivityEvent.fromJson constructor Null safety

ActivityEvent.fromJson(
  1. String json
)

Implementation

factory ActivityEvent.fromJson(String json) {
  List<String> tokens = json.split(",");
  if (tokens.length < 2) {
    return ActivityEvent.empty();
  }

  ActivityType type = ActivityType.UNKNOWN;
  if (_activityMap.containsKey(tokens.first)) {
    type = _activityMap[tokens.first]!;
  }
  int conf = int.tryParse(tokens.last)!;

  return ActivityEvent._(type, conf);
}