17
17
import io .flutter .FlutterInjector ;
18
18
import io .flutter .embedding .engine .FlutterEngine ;
19
19
import io .flutter .embedding .engine .dart .DartExecutor ;
20
+ import io .flutter .embedding .engine .FlutterEngineGroup ;
20
21
import io .flutter .embedding .engine .plugins .FlutterPlugin ;
21
22
import io .flutter .plugin .common .BinaryMessenger ;
22
23
import io .flutter .plugin .common .EventChannel ;
@@ -50,6 +51,7 @@ public class FlutterIsolatePlugin implements FlutterPlugin, MethodCallHandler, S
50
51
private Queue <IsolateHolder > queuedIsolates ;
51
52
private Map <String , IsolateHolder > activeIsolates ;
52
53
private Context context ;
54
+ private FlutterEngineGroup engineGroup ;
53
55
54
56
private static void registerWithCustomRegistrant (io .flutter .embedding .engine .FlutterEngine flutterEngine ) {
55
57
if (registrant == null ) return ;
@@ -94,6 +96,7 @@ public static void setCustomIsolateRegistrant(Class registrant) {
94
96
95
97
@ Override
96
98
public void onAttachedToEngine (FlutterPluginBinding binding ) {
99
+ engineGroup = new FlutterEngineGroup (binding .getApplicationContext ());
97
100
setupChannel (binding .getBinaryMessenger (), binding .getApplicationContext ());
98
101
}
99
102
@@ -115,14 +118,13 @@ private void startNextIsolate() {
115
118
116
119
FlutterInjector .instance ().flutterLoader ().ensureInitializationComplete (context , null );
117
120
118
- isolate .engine = new FlutterEngine (context );
119
-
120
121
FlutterCallbackInformation cbInfo = FlutterCallbackInformation .lookupCallbackInformation (isolate .entryPoint );
121
- FlutterRunArguments runArgs = new FlutterRunArguments ();
122
122
123
- runArgs .bundlePath = FlutterInjector .instance ().flutterLoader ().findAppBundlePath ();
124
- runArgs .libraryPath = cbInfo .callbackLibraryPath ;
125
- runArgs .entrypoint = cbInfo .callbackName ;
123
+ isolate .engine = engineGroup .createAndRunEngine (context , new DartExecutor .DartEntrypoint (
124
+ FlutterInjector .instance ().flutterLoader ().findAppBundlePath (),
125
+ cbInfo .callbackLibraryPath ,
126
+ cbInfo .callbackName
127
+ ));
126
128
127
129
isolate .controlChannel = new MethodChannel (isolate .engine .getDartExecutor ().getBinaryMessenger (), NAMESPACE + "/control" );
128
130
isolate .startupChannel = new EventChannel (isolate .engine .getDartExecutor ().getBinaryMessenger (), NAMESPACE + "/event" );
@@ -133,9 +135,6 @@ private void startNextIsolate() {
133
135
if (registrant != null ) {
134
136
registerWithCustomRegistrant (isolate .engine );
135
137
}
136
-
137
- DartExecutor .DartCallback dartCallback = new DartExecutor .DartCallback (context .getAssets (), runArgs .bundlePath , cbInfo );
138
- isolate .engine .getDartExecutor ().executeDartCallback (dartCallback );
139
138
}
140
139
141
140
@ Override
0 commit comments