redirectRoute method
Implementation
FutureOr<String?> redirectRoute(Map<String, String?> params, String route) {
bool isValid = paramsConverter(path: route, params: params) ==
paramsConverter(path: fullRoute, params: params);
if (isValid && _redirect != null) {
FutureOr<String?> Function(RouteProperties)? func = _redirect;
if (func is Future<String?> Function(RouteProperties)?) {
return func!(RouteProperties(
route: paramsConverter(path: route, params: params),
name: _name,
params: _params))
.then((value) => value);
} else if (func is String? Function(RouteProperties)?) {
String? path = func(RouteProperties(
route: paramsConverter(path: route, params: params),
name: _name,
params: _params)) as String?;
if (path != null) return path;
}
}
if (isValid && _redirectedChild != null) {
FutureOr<String?> Function(RouteProperties)? func = _redirectedChild;
if (func is Future<String?> Function(RouteProperties)?) {
return func!(RouteProperties(
route: paramsConverter(path: route, params: params),
name: _name,
params: _params))
.then((value) => value != null ? "$fullRoute$value" : null);
} else if (func is String? Function(RouteProperties)?) {
String? path = func(RouteProperties(
route: paramsConverter(path: route, params: params),
name: _name,
params: _params)) as String?;
if (path != null) return "$fullRoute$path";
}
} else {
return null;
}
return null;
}