Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Add mounted check. Make _getAllowFileAccessFromFileURLs final varia…
Browse files Browse the repository at this point in the history
…ble instead of getter.
  • Loading branch information
slava-r-epam committed Apr 18, 2024
1 parent b492d7e commit 279a71f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/ada_chat_flutter/lib/src/ada_web_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class _AdaWebViewState extends State<AdaWebView> {
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(
Expand Down Expand Up @@ -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!);
}
},
Expand Down

0 comments on commit 279a71f

Please sign in to comment.