You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On my flutter app, when I'm viewing content on android device, using the webview_controller. If there is a link, I use a URL launcher package to launch external browser. Then, when I navigate to bring my app up from background, it shows black screen where HTML content should be.
I have not tested on IOS device.
Expected results
Expected that when I bring up app from background, it will show app with html content.
Actual results
When I bring app from background, it's showing black screen.
FYI, I can't reproduce this in my emulator...only happens on physical Pixel device.
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.4291], locale en-US)
• Flutter version 3.10.6 on channel stable at C:\development\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f33 (10 months ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Mike\AppData\Local\Android\Sdk
• Platform android-33, build-tools 30.0.3
• ANDROID_HOME = C:\Users\Mike\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Visual Studio - develop for Windows (Visual Studio Build Tools 2017 15.9.16)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
• Visual Studio Build Tools 2017 version 15.9.28307.858
• Windows 10 SDK version 10.0.17763.0
X Visual Studio 2019 or later is required.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
What OS version is on this device @ElixirMike ? If 14 or 15, most probably you are hitting #146499 that has been recently fixed. So you will need to switch to latest master or beta and re-run your scenario to check and confirm.
Steps to reproduce
Here is my current flutter versions
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f33 (10 months ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1
I am using webview_flutter version 4.5.0.
On my flutter app, when I'm viewing content on android device, using the webview_controller. If there is a link, I use a URL launcher package to launch external browser. Then, when I navigate to bring my app up from background, it shows black screen where HTML content should be.
I have not tested on IOS device.
Expected results
Expected that when I bring up app from background, it will show app with html content.
Actual results
When I bring app from background, it's showing black screen.
FYI, I can't reproduce this in my emulator...only happens on physical Pixel device.
Code sample
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart';
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';
class MyWebView extends StatefulWidget {
final String htmlContent;
MyWebView({required this.htmlContent});
@OverRide
_MyWebViewState createState() => _MyWebViewState();
}
class _MyWebViewState extends State {
late final WebViewController _webViewController;
bool _isLoading = true;
Future _launchInBrowser(String url) async {
Uri uri = Uri.parse(url);
}
@OverRide
void initState() {
super.initState();
_webViewController = WebViewController();
_webViewController.setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (NavigationRequest request) {
// Check if the URL is an external link and not the initial content load
if (request.url != 'about:blank' &&
Uri.tryParse(request.url)?.hasAbsolutePath == true) {
_launchInBrowser(request.url);
return NavigationDecision
.prevent; // Prevent further navigation in WebView
}
return NavigationDecision.navigate; // Allow navigation within WebView
// _launchInBrowser(request.url);
// return NavigationDecision.prevent;
},
onUrlChange: (UrlChange change) {
debugPrint('url change to ${change.url}');
},
));
loadHtml();
}
Future loadHtml() async {
//
//<style>html,body{font-size: 30px;}</style>
String htmlString =
'${widget.htmlContent}';
await _webViewController.loadHtmlString(htmlString);
}
@OverRide
Widget build(BuildContext context) {
return _isLoading
? Center(
child: CircularProgressIndicator(),
)
: Container(
height: 1600, child: WebViewWidget(controller: _webViewController));
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.4291], locale en-US)
• Flutter version 3.10.6 on channel stable at C:\development\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f33 (10 months ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Mike\AppData\Local\Android\Sdk
• Platform android-33, build-tools 30.0.3
• ANDROID_HOME = C:\Users\Mike\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Visual Studio - develop for Windows (Visual Studio Build Tools 2017 15.9.16)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
• Visual Studio Build Tools 2017 version 15.9.28307.858
• Windows 10 SDK version 10.0.17763.0
X Visual Studio 2019 or later is required.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 4.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.89.0)
• VS Code at C:\Users\Mike\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.88.0
[√] Connected device (1 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4291]
[√] Network resources
• All expected network resources are available.
The text was updated successfully, but these errors were encountered: