Migrate to null safety (#17)

Named arguments are non-nullable with a default instead of a null
default. This means that code which was passing null through instead of
omitting the argument will be broken, even in unsound mode. I don't
expect any code was doing this, and this API is not one that should need
to be wrapped with argument forwarding.
6 files changed
tree: 2a5054ba27986caa7302456225a6c80eccb30dbd
  1. .github/
  2. example/
  3. lib/
  4. test/
  5. .gitignore
  6. analysis_options.yaml
  7. AUTHORS
  8. CHANGELOG.md
  9. CONTRIBUTING.md
  10. LICENSE
  11. pubspec.yaml
  12. README.md
README.md

Middleware for the http package that transparently retries failing requests.

To use this, just create an RetryClient that wraps the underlying http.Client:

import 'package:http/http.dart' as http;
import 'package:http_retry/http_retry.dart';

Future<void> main() async {
  final client = RetryClient(http.Client());
  try {
    print(await client.read('http://example.org'));
  } finally {
    client.close();
  }
}

By default, this retries any request whose response has status code 503 Temporary Failure up to three retries. It waits 500ms before the first retry, and increases the delay by 1.5x each time. All of this can be customized using the RetryClient() constructor.