7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9import androidx.annotation.VisibleForTesting;
10import io.flutter.embedding.engine.FlutterJNI;
11import io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager;
12import io.flutter.embedding.engine.loader.FlutterLoader;
13import java.util.concurrent.ExecutorService;
14import java.util.concurrent.Executors;
15import java.util.concurrent.ThreadFactory;
28 private static boolean accessed;
39 throw new IllegalStateException(
40 "Cannot change the FlutterInjector instance once it's been "
41 +
"read. If you're trying to dependency inject, be sure to do so at the beginning of "
74 @NonNull ExecutorService executorService) {
75 this.flutterLoader = flutterLoader;
76 this.deferredComponentManager = deferredComponentManager;
77 this.flutterJniFactory = flutterJniFactory;
78 this.executorService = executorService;
81 private FlutterLoader flutterLoader;
82 private DeferredComponentManager deferredComponentManager;
83 private FlutterJNI.Factory flutterJniFactory;
84 private ExecutorService executorService;
100 return deferredComponentManager;
104 return executorService;
109 return flutterJniFactory;
119 private class NamedThreadFactory
implements ThreadFactory {
120 private int threadId = 0;
122 public Thread newThread(Runnable
command) {
123 Thread thread =
new Thread(
command);
124 thread.setName(
"flutter-worker-" + threadId++);
131 private FlutterJNI.Factory flutterJniFactory;
132 private ExecutorService executorService;
139 this.flutterLoader = flutterLoader;
145 this.deferredComponentManager = deferredComponentManager;
150 this.flutterJniFactory = factory;
155 this.executorService = executorService;
159 private void fillDefaults() {
160 if (flutterJniFactory ==
null) {
164 if (executorService ==
null) {
165 executorService = Executors.newCachedThreadPool(
new NamedThreadFactory());
168 if (flutterLoader ==
null) {
169 flutterLoader =
new FlutterLoader(flutterJniFactory.provideFlutterJNI(), executorService);
182 flutterLoader, deferredComponentManager, flutterJniFactory, executorService);
std::shared_ptr< DlVertices > build()
Finalizes and the constructed DlVertices object.
Builder setFlutterLoader(@NonNull FlutterLoader flutterLoader)
Builder setFlutterJNIFactory(@NonNull FlutterJNI.Factory factory)
Builder setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
Builder setExecutorService(@NonNull ExecutorService executorService)
DeferredComponentManager deferredComponentManager()
FlutterLoader flutterLoader()
FlutterJNI.Factory getFlutterJNIFactory()
ExecutorService executorService()
static void setInstance(@NonNull FlutterInjector injector)
static FlutterInjector instance()
DlVertices::Builder Builder