5package io.flutter.embedding.engine.systemchannels;
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9import androidx.annotation.VisibleForTesting;
10import io.flutter.FlutterInjector;
12import io.flutter.embedding.engine.dart.DartExecutor;
13import io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager;
14import io.flutter.plugin.common.MethodCall;
15import io.flutter.plugin.common.MethodChannel;
16import io.flutter.plugin.common.StandardMethodCodec;
17import java.util.ArrayList;
18import java.util.HashMap;
29 private static final String TAG =
"DeferredComponentChannel";
38 @NonNull @VisibleForTesting
43 if (deferredComponentManager ==
null) {
47 String method =
call.method;
48 Map<String, Object>
args =
call.arguments();
49 Log.
v(
TAG,
"Received '" + method +
"' message.");
50 final int loadingUnitId = (
int)
args.get(
"loadingUnitId");
51 final String componentName = (String)
args.get(
"componentName");
53 case "installDeferredComponent":
54 deferredComponentManager.installDeferredComponent(loadingUnitId, componentName);
55 if (!componentNameToResults.containsKey(componentName)) {
56 componentNameToResults.put(componentName,
new ArrayList<>());
58 componentNameToResults.get(componentName).add(
result);
60 case "getDeferredComponentInstallState":
62 deferredComponentManager.getDeferredComponentInstallState(
63 loadingUnitId, componentName));
65 case "uninstallDeferredComponent":
66 deferredComponentManager.uninstallDeferredComponent(loadingUnitId, componentName);
88 deferredComponentManager =
FlutterInjector.instance().deferredComponentManager();
89 componentNameToResults =
new HashMap<>();
100 this.deferredComponentManager = deferredComponentManager;
110 if (componentNameToResults.containsKey(componentName)) {
114 componentNameToResults.get(componentName).clear();
127 if (componentNameToResults.containsKey(componentName)) {
129 result.error(
"DeferredComponent Install failure", errorMessage,
null);
131 componentNameToResults.get(componentName).clear();
static void v(@NonNull String tag, @NonNull String message)
DeferredComponentChannel(@NonNull DartExecutor dartExecutor)
void completeInstallSuccess(String componentName)
void completeInstallError(String componentName, String errorMessage)
final MethodChannel.MethodCallHandler parsingMethodHandler
void setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
static final StandardMethodCodec INSTANCE
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args