|
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 | | -} |
| 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 | +// } |
0 commit comments