send method

Stream? send(
  1. BuildContext? context,
  2. dynamic command, {
  3. String waitingText = "Waiting...",
})

Implementation

Stream? send(BuildContext? context, dynamic command,
    {String waitingText = "Waiting..."}) {
  if (context != null) {
    bool closed = false;
    showWaiting(context, waitingText).asStream().listen((_) {
      // mark waiting dialog is already closed
      closed = true;
    });
    Stream? st;
    try {
      st = runtime.send(command).asBroadcastStream();
    } catch (err) {
      _tryDismissWaiting(context, alreadyClosed: closed);
      showErrorHandler(context, err);
    }
    if (st != null) {
      st.first.then((_) {
        _tryDismissWaiting(context, alreadyClosed: closed);
      }).catchError((err) {
        _tryDismissWaiting(context, alreadyClosed: closed);
        showErrorHandler(context, err);
      });
    }
    // maybe null for no handler
    return st;
  } else {
    return runtime.send(command);
  }
}