webview修改

This commit is contained in:
fuenmao 2024-12-12 15:04:41 +08:00
parent 2ef8035678
commit 63dbe1f308
6 changed files with 86 additions and 48 deletions

View File

@ -2,9 +2,9 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'agreement_read_logic.dart'; import 'agreement_read_logic.dart';
import 'agreement_read_state.dart'; import 'agreement_read_state.dart';
@ -17,14 +17,12 @@ class AgreementReadPage extends StatefulWidget {
} }
class AgreementReadPageState extends State<AgreementReadPage> { class AgreementReadPageState extends State<AgreementReadPage> {
final AgreementReadLogic logic = Get.put(AgreementReadLogic()); final AgreementReadLogic logic = Get.put(AgreementReadLogic());
final AgreementReadState state = Get.find<AgreementReadLogic>().state; final AgreementReadState state = Get.find<AgreementReadLogic>().state;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (Platform.isAndroid) WebView.platform = AndroidWebView();
} }
@override @override
@ -70,10 +68,8 @@ class AgreementReadPageState extends State<AgreementReadPage> {
), ),
Text( Text(
"隐私政策", "隐私政策",
style: TextStyle( style:
fontSize: 16.sp, TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500),
fontWeight: FontWeight.w500
),
), ),
SizedBox( SizedBox(
width: 50.w, width: 50.w,
@ -84,13 +80,16 @@ class AgreementReadPageState extends State<AgreementReadPage> {
), ),
/// ///
const Expanded( Expanded(
child: WebView( child: InAppWebView(
initialUrl: 'https://static.23544.com/WGShare-PrivacyPolicy.html', initialUrlRequest:
), URLRequest(url: WebUri("https://static.23544.com/WGShare-PrivacyPolicy.html")),
), initialSettings: InAppWebViewSettings(
transparentBackground: true,
safeBrowsingEnabled: true,
isFraudulentWebsiteWarningEnabled: true),
)),
], ],
) ));
);
} }
} }

View File

@ -7,6 +7,7 @@ import Foundation
import agora_rtc_engine import agora_rtc_engine
import device_info_plus import device_info_plus
import flutter_inappwebview_macos
import geolocator_apple import geolocator_apple
import iris_method_channel import iris_method_channel
import package_info_plus import package_info_plus
@ -16,6 +17,7 @@ import sqflite_darwin
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin")) AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
IrisMethodChannelPlugin.register(with: registry.registrar(forPlugin: "IrisMethodChannelPlugin")) IrisMethodChannelPlugin.register(with: registry.registrar(forPlugin: "IrisMethodChannelPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))

View File

@ -331,6 +331,70 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.20.5" version: "0.20.5"
flutter_inappwebview:
dependency: "direct main"
description:
name: flutter_inappwebview
sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5"
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.1.5"
flutter_inappwebview_android:
dependency: transitive
description:
name: flutter_inappwebview_android
sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:
name: flutter_inappwebview_internal_annotations
sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
flutter_inappwebview_ios:
dependency: transitive
description:
name: flutter_inappwebview_ios
sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
flutter_inappwebview_macos:
dependency: transitive
description:
name: flutter_inappwebview_macos
sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
flutter_inappwebview_platform_interface:
dependency: transitive
description:
name: flutter_inappwebview_platform_interface
sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0+1"
flutter_inappwebview_web:
dependency: transitive
description:
name: flutter_inappwebview_web
sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
flutter_inappwebview_windows:
dependency: transitive
description:
name: flutter_inappwebview_windows
sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -1151,38 +1215,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.4.0" version: "2.4.0"
webview_flutter:
dependency: "direct main"
description:
name: webview_flutter
sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.4"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.10.4"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.5"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.9.5"
win32: win32:
dependency: transitive dependency: transitive
description: description:

View File

@ -86,7 +86,8 @@ dependencies:
preload_page_view: ^0.2.0 preload_page_view: ^0.2.0
# webview # webview
webview_flutter: ^3.0.4 #webview_flutter: ^3.0.4
flutter_inappwebview: ^6.1.5
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View File

@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <agora_rtc_engine/agora_rtc_engine_plugin.h> #include <agora_rtc_engine/agora_rtc_engine_plugin.h>
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
#include <geolocator_windows/geolocator_windows.h> #include <geolocator_windows/geolocator_windows.h>
#include <iris_method_channel/iris_method_channel_plugin_c_api.h> #include <iris_method_channel/iris_method_channel_plugin_c_api.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h> #include <permission_handler_windows/permission_handler_windows_plugin.h>
@ -14,6 +15,8 @@
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AgoraRtcEnginePluginRegisterWithRegistrar( AgoraRtcEnginePluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin")); registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin"));
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
GeolocatorWindowsRegisterWithRegistrar( GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows")); registry->GetRegistrarForPlugin("GeolocatorWindows"));
IrisMethodChannelPluginCApiRegisterWithRegistrar( IrisMethodChannelPluginCApiRegisterWithRegistrar(

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
agora_rtc_engine agora_rtc_engine
flutter_inappwebview_windows
geolocator_windows geolocator_windows
iris_method_channel iris_method_channel
permission_handler_windows permission_handler_windows