-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor webview with new package to support header override #1731
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty big change, let's have a zoom call to go over it
List<HeaderOverrideRule> parseHeaderRules(YamlList yamlList) { | ||
return yamlList.map((rule) { | ||
Map<String, String> headers = {}; | ||
(rule['headers'] as YamlMap).forEach((key, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by assuming it's a YamlMap, we make it impossible for someone to set this value in js. Please just use Map
@@ -17,6 +17,7 @@ import 'package:flutter/material.dart'; | |||
class WebViewState extends EWidgetState<EnsembleWebView> { | |||
final IFrameElement _iframeElement = IFrameElement(); | |||
HtmlElementView? htmlView; | |||
final String viewId = 'iframeElement-${DateTime.now().millisecondsSinceEpoch}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make it a unique viewId, is it causing memory leaks?
(int viewId) => _iframeElement, | ||
); | ||
|
||
return HtmlElementView( | ||
key: UniqueKey(), | ||
viewType: 'iframeElement', | ||
viewType: viewId, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add a dispose method here and dispose off the htmlView and iframeElement. That should get rid of the memory leak
|
||
// Set cookie for main domain | ||
await widget.controller.cookieManager.setCookie( | ||
url: Uri.parse('https://$cookieDomain'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't assume that it's always https. Please get the protocol from the url as well and don't hardcode it
final cookieDomain = cookieData['domain'] ?? mainUrl.host; | ||
|
||
await widget.controller.cookieManager.setCookie( | ||
url: Uri.parse('https://$cookieDomain'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
replaced 'https://pub.dev/packages/webview_flutter' with 'https://pub.dev/packages/flutter_inappwebview' to support headers override.
Added following new properties:
Test with following android and web, things worked fine by my end, iOS still needs some testing.
kpnwebview.mp4
webview.mp4