@@ -10,8 +10,35 @@ import 'package:webview_flutter_platform_interface/webview_flutter_platform_inte
10
10
import 'webview_controller.dart' ;
11
11
12
12
/// Displays a native WebView as a Widget.
13
+ ///
14
+ /// ## Platform-Specific Features
15
+ /// This class contains an underlying implementation provided by the current
16
+ /// platform. Once a platform implementation is imported, the examples below
17
+ /// can be followed to use features provided by a platform's implementation.
18
+ ///
19
+ /// {@macro webview_flutter.WebViewWidget.fromPlatformCreationParams}
20
+ ///
21
+ /// Below is an example of accessing the platform-specific implementation for
22
+ /// iOS and Android:
23
+ ///
24
+ /// ```dart
25
+ /// final WebViewController controller = WebViewController();
26
+ ///
27
+ /// final WebViewWidget webViewWidget = WebViewWidget(controller: controller);
28
+ ///
29
+ /// if (WebViewPlatform.instance is WebKitWebViewPlatform) {
30
+ /// final WebKitWebViewWidget webKitWidget =
31
+ /// webViewWidget.platform as WebKitWebViewWidget;
32
+ /// } else if (WebViewPlatform.instance is AndroidWebViewPlatform) {
33
+ /// final AndroidWebViewWidget androidWidget =
34
+ /// webViewWidget.platform as AndroidWebViewWidget;
35
+ /// }
36
+ /// ```
13
37
class WebViewWidget extends StatelessWidget {
14
38
/// Constructs a [WebViewWidget] .
39
+ ///
40
+ /// See [WebViewWidget.fromPlatformCreationParams] for setting parameters for
41
+ /// a specific platform.
15
42
WebViewWidget ({
16
43
Key ? key,
17
44
required WebViewController controller,
@@ -27,8 +54,40 @@ class WebViewWidget extends StatelessWidget {
27
54
),
28
55
);
29
56
30
- /// Constructs a [WebViewWidget] from creation params for a specific
31
- /// platform.
57
+ /// Constructs a [WebViewWidget] from creation params for a specific platform.
58
+ ///
59
+ /// {@template webview_flutter.WebViewWidget.fromPlatformCreationParams}
60
+ /// Below is an example of setting platform-specific creation parameters for
61
+ /// iOS and Android:
62
+ ///
63
+ /// ```dart
64
+ /// final WebViewController controller = WebViewController();
65
+ ///
66
+ /// PlatformWebViewWidgetCreationParams params =
67
+ /// PlatformWebViewWidgetCreationParams(
68
+ /// controller: controller.platform,
69
+ /// layoutDirection: TextDirection.ltr,
70
+ /// gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
71
+ /// );
72
+ ///
73
+ /// if (WebViewPlatform.instance is WebKitWebViewPlatform) {
74
+ /// params = WebKitWebViewWidgetCreationParams
75
+ /// .fromPlatformWebViewWidgetCreationParams(
76
+ /// params,
77
+ /// );
78
+ /// } else if (WebViewPlatform.instance is AndroidWebViewPlatform) {
79
+ /// params = AndroidWebViewWidgetCreationParams
80
+ /// .fromPlatformWebViewWidgetCreationParams(
81
+ /// params,
82
+ /// );
83
+ /// }
84
+ ///
85
+ /// final WebViewWidget webViewWidget =
86
+ /// WebViewWidget.fromPlatformCreationParams(
87
+ /// params: params,
88
+ /// );
89
+ /// ```
90
+ /// {@endtemplate}
32
91
WebViewWidget .fromPlatformCreationParams ({
33
92
Key ? key,
34
93
required PlatformWebViewWidgetCreationParams params,
0 commit comments