FetchStrategy typedef
This function is called to get FetchInstructions to fetch an image.
The instructions are executed as soon as possible after the returned Future resolves. If a delay in necessary between retries, use a delayed Future, such as Future.delayed. This is useful for implementing back-off strategies and for recovering from lack of connectivity.
uri
is the last requested image URI. A FetchStrategy may choose to use
a different URI (see FetchInstructions.uri).
If failure
is null
, then this is the first attempt to fetch the image.
If the failure
is not null
, it contains the information about the
previous attempt to fetch the image. A FetchStrategy may attempt to
recover from the failure by returning FetchInstructions that instruct
NetworkImageWithRetry to try again.
See NetworkImageWithRetry.defaultFetchStrategy for an example.
Implementation
typedef FetchStrategy = Future<FetchInstructions> Function(
Uri uri, FetchFailure? failure);