1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| Future<T> push<T extends Object?>(String name,
{Map<String, dynamic>? arguments,
bool withContainer = false,
bool opaque = true}) async {
var pushOption = BoostInterceptorOption(name,
arguments: arguments ?? <String, dynamic>{});
var future = Future<dynamic>(
() => InterceptorState<BoostInterceptorOption>(pushOption));
for (var interceptor in appState!.interceptors) {
future = future.then<dynamic>((dynamic _state) {
final state = _state as InterceptorState<dynamic>;
if (state.type == InterceptorResultType.next) {
final pushHandler = PushInterceptorHandler();
interceptor.onPush(state.data, pushHandler);
return pushHandler.future;
} else {
return state;
}
});
}
return future.then((dynamic _state) {
final state = _state as InterceptorState<dynamic>;
if (state.data is BoostInterceptorOption) {
assert(state.type == InterceptorResultType.next);
pushOption = state.data;
if (isFlutterPage(pushOption.name)) {
return appState!.pushWithResult(pushOption.name,
uniqueId: pushOption.uniqueId,
arguments: pushOption.arguments,
withContainer: withContainer,
opaque: opaque) as FutureOr<T>;
} else {
Map<String, dynamic> data = {};
data = Map<String, dynamic>.from(pushOption.arguments);
final params = CommonParams()
..pageName = pushOption.name
..arguments = data;
appState!.nativeRouterApi!.pushNativeRoute(params);
return appState!.pendNativeResult(pushOption.name);
}
} else {
assert(state.type == InterceptorResultType.resolve);
return Future<T>.value(state.data as T);
}
});
}
|