Skip to content
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

Can't load custom url on windows #2450

Open
1 of 2 tasks
Walker-ZHAO opened this issue Dec 9, 2024 · 0 comments
Open
1 of 2 tasks

Can't load custom url on windows #2450

Walker-ZHAO opened this issue Dec 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Walker-ZHAO
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Load custom scheme url by set windon.location .

On iOS/Android/macOS, shouldOverrideUrlLoading callback can be called.
On Windows, shouldOverrideUrlLoading callback can not be called. Get the error in onReceivedError callback, the error content is: error: {description: Indicates that the connection was stopped., type: 9}

Expected Behavior

On Windows, when load custom scheme url by set window.location, shouldOverrideUrlLoading callback can be called as other platforms.

Steps with code example to reproduce

Steps with code example to reproduce 1. Run the code bellow 2. Click the floating action button 3. Look at the log.
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  InAppWebViewController? _controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: InAppWebView(
        initialUrlRequest: URLRequest(url: WebUri("https://inappwebview.dev/")),
        initialSettings: InAppWebViewSettings(
          useShouldOverrideUrlLoading: true,
          useHybridComposition: false,
          mixedContentMode:
          MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
          allowsInlineMediaPlayback: true,
          allowsBackForwardNavigationGestures: false,
          isInspectable: true,
          mediaPlaybackRequiresUserGesture: false,
        ),
        onWebViewCreated: (webViewController) async {
          _controller = webViewController;
        },
        shouldOverrideUrlLoading: (controller, navigationAction) async {
            print('shouldOverrideUrlLoading: ${navigationAction.request.url}');
            return NavigationActionPolicy.ALLOW;
        }
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _controller?.evaluateJavascript(
            source:
            'window.location="ischool://function/getCommands"',
          );
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

Stacktrace/Logs

Stacktrace/Logs
[WindowsInAppWebViewController] (windows) WebView ID 2682545145696 calling "onProgressChanged" using {progress: 100}
[WindowsInAppWebViewController] (windows) WebView ID 2682545145696 calling "onReceivedError" using {error: {description: Indicates that the connection was stopped., type: 9}, request: {headers: {Upgrade-Insecure-Requests: 1}, isForMainFrame: true, method: null, url: https://inappwebview.dev/}}

Flutter version

v3.24.5

Operating System, Device-specific and/or Tool

Windows 10

Plugin version

v6.2.0-beta2

Additional information

No response

Self grab

  • I'm ready to work on this issue!
@Walker-ZHAO Walker-ZHAO added the bug Something isn't working label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant