setUrl method Null safety

Future<Duration?> setUrl(
  1. String url,
  2. {Map<String, String>? headers,
  3. Duration? initialPosition,
  4. bool preload = true}
)

Convenience method to set the audio source to a URL with optional headers, preloaded by default, with an initial position of zero by default. If headers are set, just_audio will create a cleartext local HTTP proxy on your device to forward HTTP requests with headers included.

This is equivalent to:

setAudioSource(AudioSource.uri(Uri.parse(url), headers: headers),
    initialPosition: Duration.zero, preload: true);

See setAudioSource for a detailed explanation of the options.

Implementation

Future<Duration?> setUrl(
  String url, {
  Map<String, String>? headers,
  Duration? initialPosition,
  bool preload = true,
}) =>
    setAudioSource(AudioSource.uri(Uri.parse(url), headers: headers),
        initialPosition: initialPosition, preload: preload);