chain method
Chain multiple links into one. throws ApiError when error occurs
Implementation
@nonVirtual
ApiLink chain(ApiLink nextLink) {
if (attached || nextLink.attached) {
throw ApiError(
"Cannot chain link $runtimeType with ${nextLink.runtimeType}\n"
"You cannot chain links after attaching to BaseApi",
);
}
if (disposed || nextLink.disposed) {
throw ApiError(
"Cannot chain link $runtimeType with ${nextLink.runtimeType}\n"
"You cannot chain disposed links",
);
}
if (this is HttpLink) {
throw ApiError(
"Cannot chain link $runtimeType with ${nextLink.runtimeType}\n"
"Adding link after http link will take no effect",
);
}
/// Do not chain (skip) [DebugLink] in release build.
if (isReleaseBuild) {
if (this is DebugLink) return nextLink;
if (nextLink is DebugLink) return this;
}
/// set [_firstLink] reference in [nextLink]
nextLink.__firstLink = _firstLink;
/// set reference to next link
_nextLink = nextLink;
return nextLink;
}