-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
199 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# Fetch API. | ||
|
||
> ⚠️ Requires Dart 2.19 or higher. | ||
This package provides JavaScript bindings to [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). | ||
|
||
## Features | ||
|
||
* Full request parameters coverage | ||
* Abort requests | ||
* Support canceling requests | ||
* Read response | ||
* As text | ||
* As Blob | ||
* As Stream of Uint8List | ||
* As `Blob` | ||
* As `Stream` of `Uint8List` | ||
* Support streaming of data | ||
* Get access to redirect status | ||
* Support non-200 responses | ||
* Support non-`200` responses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
import '_js.dart'; | ||
import 'abort_controller.dart'; | ||
|
||
|
||
/// The [AbortSignal] interface represents a signal object that allows you | ||
/// to communicate with a DOM request (such as a fetch request) and abort it | ||
/// if required via an [AbortController] object. | ||
@JS() | ||
@staticInterop | ||
class AbortSignal { | ||
external factory AbortSignal(); | ||
/// Returns an [AbortSignal] instance that will automatically abort | ||
/// after a specified [time]. | ||
factory AbortSignal.timeout(Duration time) | ||
=> AbortSignal._timeout(time.inMilliseconds); | ||
|
||
/// Returns an [AbortSignal] instance that is already set as aborted. | ||
external static AbortSignal abort([dynamic reason]); | ||
|
||
/// Returns an [AbortSignal] instance that will automatically abort | ||
/// after a specified [time] in milliseconds. | ||
@JS('timeout') | ||
external static AbortSignal _timeout(int time); | ||
} | ||
|
||
|
||
extension AbortSignalInstanceMembers on AbortSignal { | ||
/// A [bool] that indicates whether the request(s) the signal is | ||
/// communicating with is/are aborted (`true`) or not (`false`). | ||
external final bool aborted; | ||
|
||
/// A JavaScript value providing the abort reason, once the signal has aborted. | ||
external final dynamic reason; | ||
|
||
/// Throws the signal's abort [reason] if the signal has been aborted; | ||
/// otherwise it does nothing. | ||
external void throwIfAborted(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.