doc/api/flutter_boost_app/FlutterBoostAppState/pop.html
)
Future<bool> pop({String uniqueId, Object result}) async {
BoostContainer container;
if (uniqueId != null) {
container = _findContainerByUniqueId(uniqueId);
if (container == null) {
Logger.error('uniqueId=$uniqueId not found');
return false;
}
if (container != topContainer) {
await _removeContainer(container);
return true;
}
} else {
container = topContainer;
}
final currentPage = topContainer?.topPage?.pageInfo?.uniqueId;
assert(currentPage != null);
_completePendingResultIfNeeded(currentPage);
// 1.If uniqueId == null,indicate we simply call BoostNavigaotor.pop(),
// so we call navigator?.maybePop();
// 2.If uniqueId is topPage's uniqueId, so we navigator?.maybePop();
// 3.If uniqueId is not topPage's uniqueId, so we will remove an existing
// page in container.
if (uniqueId == null ||
uniqueId == container.pages.last.pageInfo.uniqueId) {
final handled = await container?.navigator?.maybePop(result);
if (handled != null && !handled) {
assert(container.pageInfo.withContainer);
final params = CommonParams()
..pageName = container.pageInfo.pageName
..uniqueId = container.pageInfo.uniqueId
..arguments =
(result is Map<String, dynamic>) ? result : <String, dynamic>{};
await nativeRouterApi.popRoute(params);
}
} else {
final page = container.pages.singleWhere(
(entry) => entry.pageInfo.uniqueId == uniqueId,
orElse: () => null);
container.removePage(page);
}
Logger.log('pop container, uniqueId=$uniqueId, result:$result, $container');
return true;
}