getChannelCreation static method

Channel getChannelCreation(
  1. Event event
)

Implementation

static Channel getChannelCreation(Event event) {
  try {
    Map content = jsonDecode(event.content);
    if (event.kind == 40) {
      // create channel
      Map<String, String> additional = Map.from(content);
      String? name = additional.remove("name");
      String? about = additional.remove("about");
      String? picture = additional.remove("picture");
      return Channel(
          event.id, name!, about!, picture!, event.pubkey, additional);
    } else {
      throw Exception("${event.kind} is not nip28 compatible");
    }
  } catch (e) {
    throw Exception(e.toString());
  }
}