@@ -17,9 +17,10 @@ class WebviewManager extends ValueNotifier<bool> {
17
17
final MethodChannel pluginChannel = const MethodChannel ("webview_cef" );
18
18
19
19
final Map <int , WebViewController > _webViews = < int , WebViewController > {};
20
+ final Map <int , InjectUserScripts ?> _injectUserScripts = < int , InjectUserScripts > {};
20
21
21
22
final Map <int , WebViewController > _tempWebViews = < int , WebViewController > {};
22
- InjectUserScripts ? _injectUserScripts = InjectUserScripts () ;
23
+ final Map < int , InjectUserScripts ?> _tempInjectUserScripts = < int , InjectUserScripts > {} ;
23
24
24
25
int nextIndex = 1 ;
25
26
@@ -33,7 +34,7 @@ class WebviewManager extends ValueNotifier<bool> {
33
34
final controller =
34
35
WebViewController (pluginChannel, browserIndex, loading: loading);
35
36
_tempWebViews[browserIndex] = controller;
36
- _injectUserScripts = injectUserScripts;
37
+ _tempInjectUserScripts[browserIndex] = injectUserScripts;
37
38
38
39
return controller;
39
40
}
@@ -74,7 +75,10 @@ class WebviewManager extends ValueNotifier<bool> {
74
75
75
76
void onBrowserCreated (int browserIndex, int browserId) {
76
77
_webViews[browserId] = _tempWebViews[browserIndex]! ;
78
+ _injectUserScripts[browserId] = _tempInjectUserScripts[browserIndex];
79
+
77
80
_tempWebViews.remove (browserIndex);
81
+ _tempInjectUserScripts.remove (browserIndex);
78
82
}
79
83
80
84
Future <void > methodCallhandler (MethodCall call) async {
@@ -134,7 +138,7 @@ class WebviewManager extends ValueNotifier<bool> {
134
138
int browserId = call.arguments["browserId" ] as int ;
135
139
String urlId = call.arguments["urlId" ] as String ;
136
140
137
- await _injectUserScriptIfNeeds (browserId, _injectUserScripts? .retrieveLoadStartInjectScripts () ?? []);
141
+ await _injectUserScriptIfNeeds (browserId, _injectUserScripts[browserId] ? .retrieveLoadStartInjectScripts () ?? []);
138
142
139
143
WebViewController controller =
140
144
_webViews[browserId] as WebViewController ;
@@ -144,7 +148,7 @@ class WebviewManager extends ValueNotifier<bool> {
144
148
int browserId = call.arguments["browserId" ] as int ;
145
149
String urlId = call.arguments["urlId" ] as String ;
146
150
147
- await _injectUserScriptIfNeeds (browserId, _injectUserScripts? .retrieveLoadEndInjectScripts () ?? []);
151
+ await _injectUserScriptIfNeeds (browserId, _injectUserScripts[browserId] ? .retrieveLoadEndInjectScripts () ?? []);
148
152
149
153
WebViewController controller =
150
154
_webViews[browserId] as WebViewController ;
0 commit comments