Skip to content

Commit 1f55ffc

Browse files
committed
fix some bug
1 parent 714c5bf commit 1f55ffc

File tree

6 files changed

+85
-1
lines changed

6 files changed

+85
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
3+
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
4+
5+
void main() {
6+
runApp(MaterialApp(
7+
navigatorObservers: [FlutterSmartDialog.observer],
8+
builder: FlutterSmartDialog.init(),
9+
home: const MyApp(),
10+
));
11+
}
12+
13+
class MyApp extends StatelessWidget {
14+
const MyApp({super.key});
15+
16+
@override
17+
Widget build(BuildContext context) {
18+
return Scaffold(
19+
appBar: AppBar(
20+
title: const Text("Test"),
21+
),
22+
body: Center(
23+
child: Builder(builder: (ctx) {
24+
return ElevatedButton(
25+
onPressed: () => showWebDialog(ctx),
26+
child: const Text("Click"),
27+
);
28+
}),
29+
),
30+
);
31+
}
32+
33+
void showWebDialog(BuildContext context) {
34+
SmartDialog.show(
35+
clickMaskDismiss: true,
36+
alignment: Alignment.bottomCenter,
37+
builder: (context) => Container(
38+
height: 400,
39+
padding: const EdgeInsets.symmetric(horizontal: 12),
40+
child: InAppWebView(
41+
initialData: InAppWebViewInitialData(
42+
data: _buildHtmlContent(''),
43+
mimeType: 'text/html',
44+
encoding: 'utf-8',
45+
),
46+
),
47+
),
48+
);
49+
}
50+
51+
String _buildHtmlContent(String content) {
52+
return '''
53+
<!DOCTYPE html>
54+
<html>
55+
<head>
56+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
57+
<style>
58+
body {
59+
margin: 0;
60+
padding: 0;
61+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
62+
line-height: 1.5;
63+
color: #333;
64+
}
65+
img {
66+
max-width: 100%;
67+
height: auto;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
$content
73+
</body>
74+
</html>
75+
''';
76+
}
77+
}

example/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import flutter_inappwebview_macos
89

910
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11+
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
1012
}

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies:
3030
cupertino_icons: ^1.0.0
3131
# 用于处理widget是否可见检测 https://pub.flutter-io.cn/packages/visibility_detector
3232
visibility_detector:
33+
flutter_inappwebview: ^6.1.5
3334
# mac
3435
flutter_smart_dialog:
3536
path: ../

example/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
910

1011
void RegisterPlugins(flutter::PluginRegistry* registry) {
12+
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
13+
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
1114
}

example/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
flutter_inappwebview_windows
67
)
78

89
list(APPEND FLUTTER_FFI_PLUGIN_LIST

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description:
33
An elegant Flutter Dialog solution,
44
Easily implement Toast, Loading and custom Dialog,
55
Make the use of the dialog easier!
6-
version: 4.9.8+7
6+
version: 4.9.8+8
77
homepage: https://github.com/fluttercandies/flutter_smart_dialog
88
# flutter pub publish --server=https://pub.dartlang.org
99
# flutter build web --release --base-href="/flutter_smart_dialog/web/"

0 commit comments

Comments
 (0)