Jonny Borges

format files

... ... @@ -16,7 +16,8 @@ typedef Decoder<T> = T Function(dynamic data);
typedef Progress = Function(double percent);
typedef ResponseInterceptor<T> = Future<Response<T>?> Function(Request<T> request, Type targetType, HttpClientResponse response);
typedef ResponseInterceptor<T> = Future<Response<T>?> Function(
Request<T> request, Type targetType, HttpClientResponse response);
class GetHttpClient {
String userAgent;
... ... @@ -156,16 +157,15 @@ class GetHttpClient {
final uri = _createUri(url, query);
return Request<T>(
method: method,
url: uri,
headers: headers,
bodyBytes: bodyStream,
contentLength: bodyBytes?.length ?? 0,
followRedirects: followRedirects,
maxRedirects: maxRedirects,
decoder: decoder,
responseInterceptor: responseInterceptor
);
method: method,
url: uri,
headers: headers,
bodyBytes: bodyStream,
contentLength: bodyBytes?.length ?? 0,
followRedirects: followRedirects,
maxRedirects: maxRedirects,
decoder: decoder,
responseInterceptor: responseInterceptor);
}
void _setContentLenght(Map<String, String> headers, int contentLength) {
... ... @@ -291,11 +291,14 @@ class GetHttpClient {
));
}
ResponseInterceptor<T>? _responseInterceptor<T>(ResponseInterceptor<T>? actual) {
if(actual != null) return actual;
ResponseInterceptor<T>? _responseInterceptor<T>(
ResponseInterceptor<T>? actual) {
if (actual != null) return actual;
final defaultInterceptor = defaultResponseInterceptor;
return defaultInterceptor != null
? (request, targetType, response) async => await defaultInterceptor(request, targetType, response) as Response<T>?
? (request, targetType, response) async =>
await defaultInterceptor(request, targetType, response)
as Response<T>?
: null;
}
... ... @@ -340,6 +343,7 @@ class GetHttpClient {
responseInterceptor: _responseInterceptor(responseInterceptor),
);
}
Future<Response<T>> send<T>(Request<T> request) async {
try {
var response = await _performRequest<T>(() => Future.value(request));
... ... @@ -582,17 +586,16 @@ class GetHttpClient {
// return completer.future;
// }
Future<Response<T>> delete<T>(
String url, {
Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
ResponseInterceptor<T>? responseInterceptor
}) async {
Future<Response<T>> delete<T>(String url,
{Map<String, String>? headers,
String? contentType,
Map<String, dynamic>? query,
Decoder<T>? decoder,
ResponseInterceptor<T>? responseInterceptor}) async {
try {
var response = await _performRequest<T>(
() async => _delete<T>(url, contentType, query, decoder, responseInterceptor),
() async =>
_delete<T>(url, contentType, query, decoder, responseInterceptor),
headers: headers,
);
return response;
... ...
... ... @@ -8,7 +8,6 @@ import '../../response/response.dart';
import '../interface/request_base.dart';
import '../utils/body_decoder.dart';
/// A `dart:io` implementation of `HttpRequestBase`.
class HttpRequestImpl extends HttpRequestBase {
io.HttpClient? _httpClient;
... ... @@ -58,10 +57,11 @@ class HttpRequestImpl extends HttpRequestBase {
});
final bodyBytes = (response);
final interceptionResponse = await request.responseInterceptor?.call(request, T, response);
if(interceptionResponse != null) return interceptionResponse;
final interceptionResponse =
await request.responseInterceptor?.call(request, T, response);
if (interceptionResponse != null) return interceptionResponse;
final stringBody = await bodyBytesToString(bodyBytes, headers);
final body = bodyDecoded<T>(
... ...
import 'package:flutter/widgets.dart';
class Engine{
static WidgetsBinding get instance {
class Engine {
static WidgetsBinding get instance {
return WidgetsFlutterBinding.ensureInitialized();
}
}
\ No newline at end of file
}
... ...
... ... @@ -66,12 +66,11 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
@override
Animation<double> createAnimation() {
if (curve != null) {
return CurvedAnimation(
curve: curve!, parent: _animationController!.view);
return CurvedAnimation(curve: curve!, parent: _animationController!.view);
}
return _animationController!.view;
}
@override
AnimationController createAnimationController() {
assert(_animationController == null);
... ...
... ... @@ -71,7 +71,7 @@ mixin StateMixin<T> on ListNotifier {
}
}
void futurize(Future<T> Function() body,
void futurize(Future<T> Function() body,
{T? initialData, String? errorMessage, bool useEmpty = true}) {
final compute = body;
_value ??= initialData;
... ...
... ... @@ -64,5 +64,4 @@ extension GetNumUtils on num {
// _delayMaps.remove(callback);
// }
//}
}
... ...