headers property

Map<String, dynamic>? headers
final

Optional HTTP headers applied to each HTTP request.

Example

BackgroundGeolocation.ready(Config(
  http: HttpConfig(
    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 HttpConfig.

Implementation

final Map<String, dynamic>? headers;