Merge pull request #262 from AlexVincent525/fix-crash-on-nil-or-invalid-url
Fix crash on nil/invalid URL (iOS)
This commit is contained in:
commit
0f358f037b
|
@ -98,14 +98,16 @@ public class FlutterWebViewController: FlutterMethodCallDelegate, FlutterPlatfor
|
||||||
}
|
}
|
||||||
|
|
||||||
if initialData != nil {
|
if initialData != nil {
|
||||||
let data = (initialData!["data"] as? String)!
|
let data = (initialData!["data"])!
|
||||||
let mimeType = (initialData!["mimeType"] as? String)!
|
let mimeType = (initialData!["mimeType"])!
|
||||||
let encoding = (initialData!["encoding"] as? String)!
|
let encoding = (initialData!["encoding"])!
|
||||||
let baseUrl = (initialData!["baseUrl"] as? String)!
|
let baseUrl = (initialData!["baseUrl"])!
|
||||||
webView!.loadData(data: data, mimeType: mimeType, encoding: encoding, baseUrl: baseUrl)
|
webView!.loadData(data: data, mimeType: mimeType, encoding: encoding, baseUrl: baseUrl)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
webView!.loadUrl(url: URL(string: initialUrl)!, headers: initialHeaders)
|
if let url = URL(string: initialUrl) {
|
||||||
|
webView!.loadUrl(url: url, headers: initialHeaders)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +349,7 @@ public class FlutterWebViewController: FlutterMethodCallDelegate, FlutterPlatfor
|
||||||
case "printCurrentPage":
|
case "printCurrentPage":
|
||||||
if webView != nil {
|
if webView != nil {
|
||||||
webView!.printCurrentPage(printCompletionHandler: {(completed, error) in
|
webView!.printCurrentPage(printCompletionHandler: {(completed, error) in
|
||||||
if !completed, let e = error {
|
if !completed, let _ = error {
|
||||||
result(false)
|
result(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
gestureRecognizers: widget.gestureRecognizers,
|
gestureRecognizers: widget.gestureRecognizers,
|
||||||
layoutDirection: TextDirection.rtl,
|
layoutDirection: TextDirection.rtl,
|
||||||
creationParams: <String, dynamic>{
|
creationParams: <String, dynamic>{
|
||||||
'initialUrl': widget.initialUrl,
|
'initialUrl': '${Uri.parse(widget.initialUrl)}',
|
||||||
'initialFile': widget.initialFile,
|
'initialFile': widget.initialFile,
|
||||||
'initialData': widget.initialData?.toMap(),
|
'initialData': widget.initialData?.toMap(),
|
||||||
'initialHeaders': widget.initialHeaders,
|
'initialHeaders': widget.initialHeaders,
|
||||||
|
@ -416,7 +416,7 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
onPlatformViewCreated: _onPlatformViewCreated,
|
onPlatformViewCreated: _onPlatformViewCreated,
|
||||||
gestureRecognizers: widget.gestureRecognizers,
|
gestureRecognizers: widget.gestureRecognizers,
|
||||||
creationParams: <String, dynamic>{
|
creationParams: <String, dynamic>{
|
||||||
'initialUrl': widget.initialUrl,
|
'initialUrl': '${Uri.parse(widget.initialUrl)}',
|
||||||
'initialFile': widget.initialFile,
|
'initialFile': widget.initialFile,
|
||||||
'initialData': widget.initialData?.toMap(),
|
'initialData': widget.initialData?.toMap(),
|
||||||
'initialHeaders': widget.initialHeaders,
|
'initialHeaders': widget.initialHeaders,
|
||||||
|
|
Loading…
Reference in New Issue