onHttp static method

void onHttp(
  1. dynamic callback(
    1. HttpEvent
    )
)

Subscribe to HTTP events.

Example:

BackgroundGeolocation.onHttp((HttpEvent event) {
  int status = response.status;
  bool success = response.success;
  String responseText = response.responseText;
  print('[onHttp] status: ${status}, success? ${success}, responseText: ${responseText}');
});

Implementation

static void onHttp(Function(HttpEvent) callback) {
  if (_eventsHttp == null) {
    _eventsHttp = _eventChannelHttp
        .receiveBroadcastStream()
        .map((dynamic event) => HttpEvent(event));
  }
  _registerSubscription(_eventsHttp!.listen(callback), callback);
}