Fixed null safety
This commit is contained in:
parent
a7c2a0d3dc
commit
cb56b31d10
11 changed files with 30 additions and 30 deletions
|
@ -10,9 +10,9 @@
|
|||
* Updated angel_container to 3.0.0
|
||||
* Added merge_map and updated to 2.0.0
|
||||
* Added mock_request and updated to 2.0.0
|
||||
* Updated angel_framework to 4.0.0 (Revisit TODO)
|
||||
* Updated angel_auth to 4.0.0
|
||||
* Updated angel_configuration to 4.0.0 (todo)
|
||||
* Updated angel_framework to 4.0.0 (Revisit TODO, Fix failed tests)
|
||||
* Updated angel_auth to 4.0.0 (In progress)
|
||||
* Updated angel_configuration to 4.0.0 (In progress)
|
||||
|
||||
# 3.0.0 (Non NNBD)
|
||||
* Changed Dart SDK requirements for all packages to ">=2.10.0 <3.0.0"
|
||||
|
|
|
@ -128,13 +128,13 @@ class Controller {
|
|||
|
||||
var injection = preInject(reflectedMethod!, reflector);
|
||||
|
||||
if (exposeDecl?.allowNull?.isNotEmpty == true) {
|
||||
injection.optional?.addAll(exposeDecl.allowNull);
|
||||
if (exposeDecl.allowNull.isNotEmpty == true) {
|
||||
injection.optional.addAll(exposeDecl.allowNull);
|
||||
}
|
||||
|
||||
// If there is no path, reverse-engineer one.
|
||||
var path = exposeDecl.path;
|
||||
var httpMethod = exposeDecl.method ?? 'GET';
|
||||
var httpMethod = exposeDecl.method;
|
||||
if (path == null) {
|
||||
// Try to build a route path by finding all potential
|
||||
// path segments, and then joining them.
|
||||
|
|
|
@ -471,7 +471,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
HookedServiceEvent<Id, Data, T> event,
|
||||
[HookedServiceEventListener<Id, Data, T>? callback]) {
|
||||
Future? f;
|
||||
if (callback != null && event?._canceled != true) {
|
||||
if (callback != null && event._canceled != true) {
|
||||
f = Future.sync(() => callback(event));
|
||||
}
|
||||
f ??= Future.value();
|
||||
|
@ -560,7 +560,7 @@ class HookedServiceEventDispatcher<Id, Data, T extends Service<Id, Data>> {
|
|||
/// Fires an event, and returns it once it is either canceled, or all listeners have run.
|
||||
Future<HookedServiceEvent<Id, Data, T>> _emit(
|
||||
HookedServiceEvent<Id, Data, T> event) {
|
||||
if (event?._canceled == true || event == null || listeners.isEmpty) {
|
||||
if (event._canceled == true || listeners.isEmpty) {
|
||||
return Future.value(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ class HostnameRouter {
|
|||
});
|
||||
}
|
||||
|
||||
apps ??= {};
|
||||
creators ??= {};
|
||||
apps = _parseMap(apps);
|
||||
creators = _parseMap(creators);
|
||||
var patterns = apps.keys.followedBy(creators.keys).toSet().toList();
|
||||
|
|
|
@ -26,7 +26,7 @@ resolveInjection(requirement, InjectionRequest? injection, RequestContext req,
|
|||
ResponseContext res, bool throwOnUnresolved,
|
||||
[Container? container]) async {
|
||||
var propFromApp;
|
||||
container ??= req?.container ?? res?.app?.container;
|
||||
container ??= req.container ?? res.app?.container;
|
||||
|
||||
if (requirement == RequestContext) {
|
||||
return req;
|
||||
|
|
|
@ -122,8 +122,7 @@ class Parameter {
|
|||
/// Obtains a value for this parameter from a [RequestContext].
|
||||
getValue(RequestContext req) {
|
||||
if (cookie?.isNotEmpty == true) {
|
||||
return req.cookies!.firstWhere((c) => c.name == cookie)?.value ??
|
||||
defaultValue;
|
||||
return req.cookies!.firstWhere((c) => c.name == cookie).value;
|
||||
}
|
||||
if (header?.isNotEmpty == true) {
|
||||
return req.headers!.value(header!) ?? defaultValue;
|
||||
|
|
|
@ -24,7 +24,7 @@ RequestHandler chain(Iterable<RequestHandler> handlers) {
|
|||
Future Function()? runPipeline;
|
||||
|
||||
for (var handler in handlers) {
|
||||
if (handler == null) break;
|
||||
//if (handler == null) break;
|
||||
|
||||
if (runPipeline == null) {
|
||||
runPipeline = () => Future.sync(() => handler(req, res));
|
||||
|
@ -108,7 +108,10 @@ class Routable extends Router<RequestHandler?> {
|
|||
}
|
||||
|
||||
final handlerSequence = <RequestHandler>[];
|
||||
handlerSequence.addAll(middleware as Iterable<FutureOr<dynamic>? Function(RequestContext<dynamic>, ResponseContext<dynamic>)>? ?? []);
|
||||
handlerSequence.addAll(middleware as Iterable<
|
||||
FutureOr<dynamic>? Function(
|
||||
RequestContext<dynamic>, ResponseContext<dynamic>)>? ??
|
||||
[]);
|
||||
handlerSequence.addAll(handlers);
|
||||
|
||||
return super.addRoute(method, path.toString(), handler,
|
||||
|
|
|
@ -159,7 +159,7 @@ class Angel extends Routable {
|
|||
'This route will be ignored, and no requests will ever reach it.');
|
||||
}
|
||||
|
||||
return super.addRoute(method, path, handler, middleware: middleware ?? []);
|
||||
return super.addRoute(method, path, handler, middleware: middleware);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -225,21 +225,21 @@ class Angel extends Routable {
|
|||
|
||||
_flattened!.dumpTree(
|
||||
callback: callback,
|
||||
header: header?.isNotEmpty == true
|
||||
header: header.isNotEmpty == true
|
||||
? header
|
||||
: (environment.isProduction
|
||||
? 'Dumping flattened route tree:'
|
||||
: 'Dumping route tree:'),
|
||||
tab: tab ?? ' ');
|
||||
tab: tab);
|
||||
} else {
|
||||
super.dumpTree(
|
||||
callback: callback,
|
||||
header: header?.isNotEmpty == true
|
||||
header: header.isNotEmpty == true
|
||||
? header
|
||||
: (environment.isProduction
|
||||
? 'Dumping flattened route tree:'
|
||||
: 'Dumping route tree:'),
|
||||
tab: tab ?? ' ');
|
||||
tab: tab);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ class Angel extends Routable {
|
|||
/// Runs with DI, and *always* reflects. Prefer [runContained].
|
||||
Future runReflected(Function handler, RequestContext req, ResponseContext res,
|
||||
[Container? container]) {
|
||||
container ??= req?.container ?? res?.app?.container;
|
||||
container ??= req.container ?? res.app?.container;
|
||||
var h = handleContained(
|
||||
handler,
|
||||
_preContained[handler] = preInject(handler, container!.reflector),
|
||||
|
|
|
@ -9,11 +9,11 @@ export 'http_response_context.dart';
|
|||
|
||||
/// Boots a shared server instance. Use this if launching multiple isolates.
|
||||
Future<HttpServer> startShared(address, int port) =>
|
||||
HttpServer.bind(address ?? '127.0.0.1', port ?? 0, shared: true);
|
||||
HttpServer.bind(address ?? '127.0.0.1', port, shared: true);
|
||||
|
||||
Future<HttpServer> Function(dynamic, int) startSharedSecure(
|
||||
SecurityContext securityContext) {
|
||||
return (address, int port) => HttpServer.bindSecure(
|
||||
address ?? '127.0.0.1', port ?? 0, securityContext,
|
||||
address ?? '127.0.0.1', port, securityContext,
|
||||
shared: true);
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
|||
return __allowedEncodings ??= correspondingRequest!.headers!
|
||||
.value('accept-encoding')
|
||||
?.split(',')
|
||||
?.map((s) => s.trim())
|
||||
?.where((s) => s.isNotEmpty)
|
||||
?.map((str) {
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.map((str) {
|
||||
// Ignore quality specifications in accept-encoding
|
||||
// ex. gzip;q=0.8
|
||||
if (!str.contains(';')) return str;
|
||||
|
|
|
@ -119,9 +119,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
|
|||
return __allowedEncodings ??= correspondingRequest!.headers!
|
||||
.value('accept-encoding')
|
||||
?.split(',')
|
||||
?.map((s) => s.trim())
|
||||
?.where((s) => s.isNotEmpty)
|
||||
?.map((str) {
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.map((str) {
|
||||
// Ignore quality specifications in accept-encoding
|
||||
// ex. gzip;q=0.8
|
||||
if (!str.contains(';')) return str;
|
||||
|
|
Loading…
Reference in a new issue