Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fluttercandies/http_client_helper
A Flutter plugin for http request with cancel and retry fuctions.
https://github.com/fluttercandies/http_client_helper
dart flutter-plugin http-client retry-fuctions
Last synced: 6 days ago
JSON representation
A Flutter plugin for http request with cancel and retry fuctions.
- Host: GitHub
- URL: https://github.com/fluttercandies/http_client_helper
- Owner: fluttercandies
- License: mit
- Created: 2019-02-14T15:17:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-24T10:07:35.000Z (5 months ago)
- Last Synced: 2024-06-24T11:39:19.602Z (5 months ago)
- Topics: dart, flutter-plugin, http-client, retry-fuctions
- Language: Dart
- Size: 92.8 KB
- Stars: 24
- Watchers: 3
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# http_client_helper
[![pub package](https://img.shields.io/pub/v/http_client_helper.svg)](https://pub.dartlang.org/packages/http_client_helper)
A Flutter plugin for http request with cancel and retry fuctions.
## Usage
To use this plugin, add `http_client_helper` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
### Example
``` dart
cancellationToken = new CancellationToken();
try {
await HttpClientHelper.get(url,
cancelToken: cancellationToken,
timeRetry: Duration(milliseconds: 100),
retries: 3,
timeLimit: Duration(seconds: 5))
.then((response) {
setState(() {
msg = response.body;
});
});
} on TimeoutException catch (_) {
setState(() {
msg = "TimeoutException";
});
} on OperationCanceledError catch (_) {
setState(() {
msg = "cancel";
});
} catch (e) {
setState(() {
msg = "$e";
});
}
```
Please see the example app of this plugin for a full example.