Skip to content

Commit 701c3c8

Browse files
committed
added support for reloading url with headers
1 parent 24abc82 commit 701c3c8

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ private void reload(MethodCall call, MethodChannel.Result result) {
204204
private void reloadUrl(MethodCall call, MethodChannel.Result result) {
205205
if (webViewManager != null) {
206206
String url = call.argument("url");
207-
webViewManager.reloadUrl(url);
207+
Map<String, String> headers = call.argument("headers");
208+
if (headers != null) {
209+
webViewManager.reloadUrl(url, headers);
210+
} else {
211+
webViewManager.reloadUrl(url);
212+
}
213+
208214
}
209215
result.success(null);
210216
}

android/src/main/java/com/flutter_webview_plugin/WebviewManager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,10 @@ void openUrl(
373373
webView.getSettings().setUseWideViewPort(useWideViewPort);
374374

375375
// Handle debugging
376-
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
377-
376+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
377+
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
378+
}
379+
378380
webViewClient.updateInvalidUrlRegex(invalidUrlRegex);
379381

380382
if (geolocationEnabled) {
@@ -416,6 +418,10 @@ void reloadUrl(String url) {
416418
webView.loadUrl(url);
417419
}
418420

421+
void reloadUrl(String url, Map<String, String> headers) {
422+
webView.loadUrl(url, headers);
423+
}
424+
419425
void close(MethodCall call, MethodChannel.Result result) {
420426
if (webView != null) {
421427
ViewGroup vg = (ViewGroup) (webView.getParent());

lib/src/base.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ class FlutterWebviewPlugin {
202202
Future<Null> show() async => await _channel.invokeMethod('show');
203203

204204
// Reload webview with a url
205-
Future<Null> reloadUrl(String url) async {
206-
final args = <String, String>{'url': url};
205+
Future<Null> reloadUrl(String url, {Map<String, String> headers}) async {
206+
final args = <String, dynamic>{'url': url};
207+
if (headers != null) {
208+
args['headers'] = headers;
209+
}
207210
await _channel.invokeMethod('reloadUrl', args);
208211
}
209212

0 commit comments

Comments
 (0)