10000 [webview_flutter_platform_interface] Adds missing build params for We… · flutter/plugins@7ad8ae5 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 7ad8ae5

Browse files
[webview_flutter_platform_interface] Adds missing build params for WebViewWidget (#6279)
1 parent 31ffdb5 commit 7ad8ae5

File tree

4 files changed

+78
-4
lines changed

4 files changed

+78
-4
lines changed

packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## NEXT
1+
## 1.9.2
22

33
* Fixes avoid_redundant_argument_values lint warnings and minor typos.
44
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/106316).
5+
* Adds missing build params for v4 WebViewWidget interface.
56

67
## 1.9.1
78

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/platform_webview_widget.dart

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/foundation.dart';
6+
import 'package:flutter/g 8000 estures.dart';
57
import 'package:flutter/widgets.dart';
68
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
9+
import 'package:webview_flutter_platform_interface/v4/src/platform_webview_controller.dart';
710

811
import 'webview_platform.dart';
912

@@ -33,5 +36,75 @@ abstract class PlatformWebViewWidget extends PlatformInterface {
3336
/// Builds a new WebView.
3437
///
3538
/// Returns a Widget tree that embeds the created web view.
36-
Widget build(BuildContext context);
39+
Widget build(BuildParams params);
40+
}
41+
42+
/// Describes the parameters necessary for displaying the platform WebView.
43+
///
44+
/// Platform specific implementations can add additional fields by extending
45+
/// this class.
46+
///
47+
/// {@tool sample}
48+
/// This example demonstrates how to extend the [BuildParams] to provide
49+
/// additional platform specific parameters.
50+
///
51+
/// When extending [BuildParams], additional parameters should always accept
52+
/// `null` or have a default value to prevent breaking changes.
53+
///
54+
/// ```dart
55+
/// @immutable
56+
/// class WebKitBuildParams extends BuildParams {
57+
/// WebKitBuildParams(
58+
/// super.context, {
59+
/// required super.controller,
60+
/// super.layoutDirection,
61+
/// super.gestureRecognizers,
62+
/// this.platformSpecificFieldExample,
63+
/// });
64+
///
65+
/// WebKitBuildParams.fromBuildParams(
66+
/// BuildParams params, {
67+
/// Object? platformSpecificFieldExample,
68+
/// }) : this(
69+
/// params.context,
70+
/// controller: params.controller,
71+
/// layoutDirection: params.layoutDirection,
72+
/// gestu 8000 reRecognizers: params.gestureRecognizers,
73+
/// platformSpecificFieldExample: platformSpecificFieldExample,
74+
/// );
75+
///
76+
/// final Object? platformSpecificFieldExample;
77+
/// }
78+
/// ```
79+
/// {@end-tool}
80+
@immutable
81+
class BuildParams {
82+
/// Constructs a [BuildParams].
83+
const BuildParams(
84+
this.context, {
85+
required this.controller,
86+
this.layoutDirection = TextDirection.ltr,
87+
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
88+
});
89+
90+
/// Describes the part of the user interface represented by the returned
91+
/// widget.
92+
final BuildContext context;
93+
94+
/// Controls the embedded WebView for the current platform.
95+
final PlatformWebViewController controller;
96+
97+
/// The layout direction to use for the embedded WebView.
98+
final TextDirection layoutDirection;
99+
100+
/// Specifies which gestures should be consumed by the web view.
101+
///
102+
/// It is possible for other gesture recognizers to be competing with the web
103+
/// view on pointer events, e.g if the web view is inside a [ListView] the
104+
/// [ListView] will want to handle vertical drags. The web view will claim
105+
/// gestures that are recognized by any of the recognizers on this list.
106+
///
107+
/// When this is empty, the web view will only handle pointer events for
108+
/// gestures that were not claimed by any other gesture recognizer.
109+
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;
37110
}

packages/webview_flutter/webview_flutter_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/webview_flutte
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview_flutter%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 1.9.1
7+
version: 1.9.2
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

packages/webview_flutter/webview_flutter_platform_interface/test/src/v4/platform_webview_widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ExtendsWebViewWidgetDelegate extends PlatformWebViewWidget {
8282
: super.implementation(params);
8383

8484
@override
85-
Widget build(BuildContext context) {
85+
Widget build(BuildParams params) {
8686
throw UnimplementedError(
8787
'build is not implemented for ExtendedWebViewWidgetDelegate.');
8888
}

0 commit comments

Comments
 (0)
0