baseUrl property

String? baseUrl
final

Set the API base URL.

Base URLs should always end in /.

Correct:

  • Base URL: http://example.com/api/
  • Endpoint: foo/bar/
  • Result: http://example.com/api/foo/bar/

Incorrect:

  • Base URL: http://example.com/api
  • Endpoint: foo/bar/
  • Result: http://example.com/foo/bar/

When you specify a relative baseUrl. The Dio instance passed to the constructor should have it defined. When you don't specify the baseUrl. The Dio instance passed to the constructor should have it defined. Otherwise the path field of any HttpMethod like POST should have the full URL.

Implementation

final String? baseUrl;