JsonFetcher<T> class
General fetcher to use JsonHttpFetcher in a functional way.
await for(final ok in JsonFetcher<bool>(client, (json) => json['ok'] as bool).fetch(url)) {
if(ok) {
print("Good");
} else {
print("Bad");
}
};
- Inheritance
-
- Object
- JsonHttpFetcher<
T> - JsonFetcher
- Implementers
Constructors
-
JsonFetcher(JsonHttpClient client, FutureOr<
T> converter(dynamic json)) -
const
Properties
-
converter
→ FutureOr<
T> Function(dynamic json) -
Converter from json to object
json will be decoded from string using jsonDecode
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fetch(
String url, {dynamic nocache = false, dynamic allowErrorWhenCacheExists = false, Map< String, String> ? headers, String? cacheUrl, String? body, bool usePost = false}) → Stream<T> -
by default, if cached version is available then errors will not be pushed to stream
nocache
skip cached versionallowErrorWhenCacheExists
throw errors even if cache is exists ifcacheUrl
is specified, then content will be cached under itinherited -
get(
String url, {Map< String, String> ? headers, String? body, bool usePost = false}) → Future<T> -
just get without caching
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
String source) → FutureOr< T> -
implement me: returns object parsed from json
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited