Load an H5 page using flutter_webview_plugin to jump from the DART page to the H5 page, which can either return to the DART page or jump to another DART page. After the test, it can be used normally on Android, but a blank screen is displayed when the Web page is closed on ios. The web page is not close, and the reason has not been found…

import 'dart:io'; import 'dart:async'; import 'package:flutter/material.dart'; import 'package:nav_router/nav_router.dart'; // Import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'class_room.dart'; // Dart file class ClassRoomWebView extends StatefulWidget {ClassRoomWebView({this.url}) : super(); final String url; Override _ClassRoomWebViewState createState() => _ClassRoomWebViewState(); } class _ClassRoomWebViewState extends State<ClassRoomWebView> { BuildContext _context; FlutterWebviewPlugin flutterWebviewPlugin = FlutterWebviewPlugin(); double _navBarHeight = 27; @override void initState() {super.initState(); FlutterWebviewPlugin. OnUrlChanged. Listen (loadUrl () {/ / WebviewScaffold loading url changes to trigger this method / / print (" = = = > > the current url: $loadUrl '); / / h5 points out button, close webView if (loadUrl. EndsWith ('/backapp)) {flutterWebviewPlugin. Close (); pop(); Else if (loadurl.endswith ('/policy')){// Because flutter_webview_plugin is a layer view floating on flutterUI, it is not in the widget tree, Jump to dart page, need to hide out web pages, and hop back to display a web page flutterWebviewPlugin. Hide (); routePush(ClassRoomPage()).then((value) { flutterWebviewPlugin.show(); flutterWebviewPlugin.reloadUrl(widget.url); }); / / jump to dart page, also can close off the web page, and then jump back to create a web page / / flutterWebviewPlugin close (); // routePush(ClassRoomPage()).then((value){ // flutterWebviewPlugin.launch(widget.url, // rect: New rect.fromltwh (// Set the web page size // 0.0, // _navBarHeight, // mediaquery.of (_context).sie.width, // MediaQuery.of(_context).size.height-_navBarHeight, // ), // ); / /}); }}); / / load error when listening / / flutterWebviewPlugin onHttpError. Listen ((error) {/ / print (' load error: ${error. Code} ${error. Url} '); / /}); / / load state changes to monitor / / flutterWebviewPlugin onStateChanged. Listen ((state) {/ / print (' status monitoring: ${state. Type. The toString ()} "); / /}); } @override void dispose() { flutterWebviewPlugin.dispose(); // Dispose flutter_webview_plugin super.dispose(); } @override Widget build(BuildContext context) { _context = context; _navBarHeight = MediaQuery.of(context).padding.top; Return WebviewScaffold(// The navigation bar is H5, which needs to be set to the height of the bangs. AppBar: PreferredSize(child: Container(color: Colors.white, ), preferredSize: Size.fromHeight(0) ), url: widget.url, initialChild: Container( color: Colors. Green, child: Center(child: Text(' loading... ',style: TextStyle(fontSize: 14, color: Colors.black),), ), ), ); }}Copy the code