headers property

Map<String, dynamic>? headers
getter/setter pair

Optional HTTP headers applied to each HTTP request.

Example

CoffeeBackgroundGeolocation.init(Config(
  url: 'https://my.server.com',
  headers: {
    'authorization': "Bearer <a secret key>",
    'X-FOO": "BAR'
  }
));

Observing incoming requests at your server:

POST /locations
{
  "host": "tracker.transistorsoft.com",
  "content-type": "application/json",
  "content-length": "456"
  .
  .
  .
  "authorization": "Bearer <a secret key>",
  "X-FOO": "BAR"
}

Note: The plugin automatically applies a number of required headers, including "content-type": "application/json" See also: HTTP Guide at HttpEvent.

Implementation

///
  /// ## Example
  /// ```dart
  /// CoffeeBackgroundGeolocation.init(Config(
  ///   url: 'https://my.server.com',
  ///   headers: {
  ///     'authorization': "Bearer <a secret key>",
  ///     'X-FOO": "BAR'
  ///   }
  /// ));
  /// ```
  ///
  /// Observing incoming requests at your server:
  ///
  /// ```
  /// POST /locations
  /// {
  ///   "host": "tracker.transistorsoft.com",
  ///   "content-type": "application/json",
  ///   "content-length": "456"
  ///   .
  ///   .
  ///   .
  ///   "authorization": "Bearer <a secret key>",
  ///   "X-FOO": "BAR"
  /// }
  /// ```
  ///
  ///  **Note:**  The plugin automatically applies a number of required headers, including `"content-type": "application/json"`
  /// __See also:__ __HTTP Guide__ at [HttpEvent].
  ///
  Map<String, dynamic>? headers;