Jonny Borges
Committed by GitHub

Merge pull request #2456 from shawon1fb/debouncer_null_safe

Debouncer null safe
... ... @@ -7,7 +7,9 @@ import '../status/http_status.dart';
class GraphQLResponse<T> extends Response<T> {
final List<GraphQLError>? graphQLErrors;
GraphQLResponse({T? body, this.graphQLErrors}) : super(body: body);
GraphQLResponse.fromResponse(Response res)
: graphQLErrors = null,
super(
... ... @@ -31,6 +33,26 @@ class Response<T> {
this.body,
});
Response<T> copyWith({
Request? request,
int? statusCode,
Stream<List<int>>? bodyBytes,
String? bodyString,
String? statusText,
Map<String, String>? headers,
T? body,
}) {
return Response<T>(
request: request ?? this.request,
statusCode: statusCode ?? this.statusCode,
bodyBytes: bodyBytes ?? this.bodyBytes,
bodyString: bodyString ?? this.bodyString,
statusText: statusText ?? this.statusText,
headers: headers ?? this.headers,
body: body ?? this.body,
);
}
/// The Http [Request] linked with this [Response].
final Request? request;
... ...
... ... @@ -9,14 +9,14 @@ import 'dart:async';
/// delayed( () => print( 'called after 1 sec' ));
/// ```
class Debouncer {
final Duration? delay;
final Duration delay;
Timer? _timer;
Debouncer({this.delay});
Debouncer({required this.delay});
void call(void Function() action) {
_timer?.cancel();
_timer = Timer(delay!, action);
_timer = Timer(delay, action);
}
/// Notifies if the delayed call is active.
... ...