From 279a71f7336668f083c6015f0808e1d8c696ee0d Mon Sep 17 00:00:00 2001 From: Slava Riabinin Date: Thu, 18 Apr 2024 22:10:06 +0400 Subject: [PATCH] Add `mounted` check. Make _getAllowFileAccessFromFileURLs final variable instead of getter. --- packages/ada_chat_flutter/lib/src/ada_web_view.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ada_chat_flutter/lib/src/ada_web_view.dart b/packages/ada_chat_flutter/lib/src/ada_web_view.dart index 651a38699..fe88aea77 100644 --- a/packages/ada_chat_flutter/lib/src/ada_web_view.dart +++ b/packages/ada_chat_flutter/lib/src/ada_web_view.dart @@ -99,14 +99,14 @@ class _AdaWebViewState extends State { verticalScrollBarEnabled: false, useWideViewPort: false, disableDefaultErrorPage: true, - allowFileAccessFromFileURLs: _getAllowFileAccessFromFileURLs, + allowFileAccessFromFileURLs: _allowFileAccessFromFileURLs, allowsBackForwardNavigationGestures: false, ); /// Unsafe feature. Needed if the embed.html file is not hosted anywhere, then /// the file from the assets will be used. /// More about it (here)[https://inappwebview.dev/docs/webview/in-app-webview#antipatterns]. - bool get _getAllowFileAccessFromFileURLs => widget.urlRequest == null; + late final bool _allowFileAccessFromFileURLs = widget.urlRequest == null; @override Widget build(BuildContext context) => InAppWebView( @@ -212,7 +212,7 @@ console.log("adaSettings updated"); Future.delayed( widget.greetingDelay, () { - if (widget.greeting != null) { + if (widget.greeting != null && mounted) { widget.controller?.triggerAnswer(widget.greeting!); } },