Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

InternalStoragePathHandler for Android toMap is calling itself recursively #2451

Open
2 tasks done
roberthofstra opened this issue Dec 10, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@roberthofstra
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

call stack overflow dart when using a Internal

Expected Behavior

No stack call overflow

Steps with code example to reproduce

Steps with code example to reproduce
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';



class ExpWebViewAssetLocalLoaderPage extends StatefulWidget {
  const ExpWebViewAssetLocalLoaderPage({super.key, required this.gamesBaseDir, required this.gameStartPath, required this.gameUrl});

  final String gamesBaseDir;
  final String gameStartPath;
  final String gameUrl;

  @override
  State<ExpWebViewAssetLocalLoaderPage> createState() => _MyAppState();
}

class _MyAppState extends State<ExpWebViewAssetLocalLoaderPage> {
  final GlobalKey webViewKey = GlobalKey();


  @override
  Widget build(BuildContext context) {

    InAppWebViewSettings settings = InAppWebViewSettings(
        isInspectable: kDebugMode,

        // Setting this off for security. Off by default for SDK versions >= 16.
        allowFileAccessFromFileURLs: false,
        // Off by default, deprecated for SDK versions >= 30.
        allowUniversalAccessFromFileURLs: false,

        // Keeping these off is less critical but still a good idea, especially if your app is not
        // using file:// or content:// URLs.
        allowFileAccess: false,
        allowContentAccess: false,

        // Basic WebViewAssetLoader with custom domain
        webViewAssetLoader: WebViewAssetLoader(
            domain: "my.custom.domain.com",
            pathHandlers: [ InternalStoragePathHandler(
                directory: '${widget.gamesBaseDir}/${widget.gameStartPath}/',
                path: '/${widget.gameStartPath}/')
            ]));

    return Scaffold(
        appBar: AppBar(
          title: const Text('WebView Asset Loader'),
        ),
        body: Column(children: <Widget>[
          Expanded(
              child: InAppWebView(
                key: webViewKey,
                initialUrlRequest: URLRequest(
                    url: WebUri(
                        "https://my.custom.domain.com/${widget.gameUrl}")),
                initialSettings: settings,
              )),
        ]));
  }
}

Stacktrace/Logs

Stacktrace/Logs
#0      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:196:3)
#1      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#2      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#3      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#4      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#5      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#6      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)
#7      AndroidInternalStoragePathHandler.toMap (package:flutter_inappwebview_android/src/webview_asset_loader.dart:198:16)

Flutter version

3.22.3

Operating System, Device-specific and/or Tool

Android

Plugin version

v6.0.0

Additional information

No response

Self grab

  • I'm ready to work on this issue!
@ChenTian-plaud
Copy link

amazing👍!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants