flutter_inappwebview
flutter_inappwebview copied to clipboard
Web platform not working: createPlatformInAppBrowser is not implemented on the current platform
Hi! 👋
I have, indeed:
- [x] read the Getting Started section
- [x] already searched for the same problem
Environment
Technology | Version |
---|---|
Flutter version | 3.19.1 |
Plugin version | 6.0.0 |
Google Chrome version | 122.0.6261.94 (Official Build) (64-bit) |
Description
I'm having trouble making InAppBrowser work in web
platform, getting this error when trying the basic usage:
That is, of course, even after placing this snipping within the head
of web/index.html
:
<script type="application/javascript" src="/assets/packages/flutter_inappwebview_web/assets/web/web_support.js" defer></script>
Otherwise, plugin works well in APK build.
Images
Stacktrace/Logcat
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following UnimplementedError was thrown building Builder:
createPlatformInAppBrowser is not implemented on the current platform.
The relevant error-causing widget was:
MaterialApp MaterialApp:file:///C:/Users/Emi/OneDrive/Work/project/frontend/app/lib/main.dart:45:11
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3 throw_
packages/flutter_inappwebview_platform_interface/src/inappwebview_platform.dart 274:5 createPlatformInAppBrowser
packages/flutter_inappwebview_platform_interface/src/in_app_browser/platform_in_app_browser.dart 130:30 new
packages/flutter_inappwebview/src/in_app_browser/in_app_browser.dart 39:25 fromPlatformCreationParams
(...)
👋 @luzdealba
NOTE: This comment is auto-generated.
Are you sure you have already searched for the same problem?
Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!
If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.
In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE]
or ios WKWebView [MY ERROR HERE]
keywords.
Following these steps can save you, me, and other people a lot of time, thanks!
yeah, I'm having a same issue here, is there anyway to solve this problem, please help
is there a workaround existing for this?
I want to log in to a 3rd party website and the obtain cookie via CookieManager
Same issue here
I noticed that implementation seems to work alright if I use InAppWebView
(see basic usage) instead of InAppBrowser
.
@FaFre that might be a workaround of sorts 🤷♂️
@luzdealba can you share your code please? I tried that as well but didn't had any success.
@luzdealba can you share your code please? I tried that as well but didn't had any success.
Sure!
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:project/widgets/drawer.dart';
const frontend = "https://www.google.com/";
class InAppWebViewerScreen extends StatefulWidget {
const InAppWebViewerScreen({super.key});
@override
State<InAppWebViewerScreen> createState() => _MyAppState();
}
class _MyAppState extends State<InAppWebViewerScreen> {
final GlobalKey webViewKey = GlobalKey();
InAppWebViewController? webViewController;
InAppWebViewSettings settings = InAppWebViewSettings(
allowsInlineMediaPlayback: true,
javaScriptEnabled: true,
isInspectable: kDebugMode,
mediaPlaybackRequiresUserGesture: false,
);
PullToRefreshController? pullToRefreshController;
String url = "";
double progress = 0;
final urlController = TextEditingController();
@override
void initState() {
super.initState();
pullToRefreshController = kIsWeb
? null
: PullToRefreshController(
settings: PullToRefreshSettings(
color: Colors.blue,
),
onRefresh: () async {
if (defaultTargetPlatform == TargetPlatform.android) {
webViewController?.reload();
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
webViewController?.loadUrl(
urlRequest:
URLRequest(url: await webViewController?.getUrl()));
}
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Project")),
drawer: const DrawerWidget(),
body: SafeArea(
child: Column(children: <Widget>[
Expanded(
child: Stack(
children: [
InAppWebView(
key: webViewKey,
initialUrlRequest: URLRequest(url: WebUri(frontend)),
initialSettings: settings,
pullToRefreshController: pullToRefreshController,
onWebViewCreated: (controller) {
webViewController = controller;
},
onLoadStart: (controller, url) {
setState(() {
this.url = url.toString();
urlController.text = this.url;
});
},
onPermissionRequest: (controller, request) async {
return PermissionResponse(
resources: request.resources,
action: PermissionResponseAction.GRANT);
},
onLoadStop: (controller, url) async {
pullToRefreshController?.endRefreshing();
setState(() {
this.url = url.toString();
urlController.text = this.url;
});
},
onReceivedError: (controller, request, error) {
pullToRefreshController?.endRefreshing();
},
onProgressChanged: (controller, progress) {
if (progress == 100) {
pullToRefreshController?.endRefreshing();
}
setState(() {
this.progress = progress / 100;
urlController.text = url;
});
},
onUpdateVisitedHistory: (controller, url, androidIsReload) {
setState(() {
this.url = url.toString();
urlController.text = this.url;
});
},
onConsoleMessage: (controller, consoleMessage) {
if (kDebugMode) {
print(consoleMessage);
}
},
),
progress < 1.0
? LinearProgressIndicator(value: progress)
: Container(),
],
),
),
])));
}
}