createStream method Null safety

Future<StreamingMount?> createStream(
  1. String type,
  2. {String? name,
  3. String? description,
  4. String? metadata,
  5. int? id,
  6. String? pin,
  7. List<CreateMediaItem>? media,
  8. String? secret,
  9. bool? isPrivate,
  10. bool? permanent,
  11. String? adminKey}
)

Create a new streaming Mount-point type = rtp|live|ondemand|rtsp rtp = stream originated by an external tool (e.g., gstreamer or ffmpeg) and sent to the plugin via RTP live = local file streamed live to multiple viewers (multiple viewers = same streaming context) ondemand = local file streamed on-demand to a single listener (multiple viewers = different streaming contexts) rtsp = stream originated by an external RTSP feed (only available if libcurl support was compiled)

Implementation

Future<StreamingMount?> createStream(String type,
    {String? name, String? description, String? metadata, int? id, String? pin, List<CreateMediaItem>? media, String? secret, bool? isPrivate, bool? permanent, String? adminKey}) async {
  var payload = {
    "request": "create",
    "type": type,
    if (adminKey != null) "admin_key": adminKey,
    if (id != null) "id": id,
    if (name != null) "name": name,
    if (description != null) "description": description,
    if (metadata != null) "metadata": metadata,
    if (secret != null) "secret": secret,
    if (pin != null) "pin": pin,
    if (isPrivate != null) "is_private": isPrivate,
    if (permanent != null) "permanent": permanent,
    if (media != null) "media": media,
  };
  var response = await this.send(data: payload);
  if (response['streaming'] == 'created') {
    return StreamingMount.fromJson(response);
  }
  return null;
}