mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[pointer_interceptor] Migrate to null safety (#286)
This commit is contained in:
@ -38,4 +38,5 @@ These are the available packages in this repository.
|
|||||||
| [multicast_dns](./packages/multicast_dns/) | [](https://pub.dev/packages/multicast_dns) |
|
| [multicast_dns](./packages/multicast_dns/) | [](https://pub.dev/packages/multicast_dns) |
|
||||||
| [palette_generator](./packages/palette_generator/) | [](https://pub.dartlang.org/packages/palette_generator) |
|
| [palette_generator](./packages/palette_generator/) | [](https://pub.dartlang.org/packages/palette_generator) |
|
||||||
| [pigeon](./packages/pigeon/) | [](https://pub.dev/packages/pigeon) |
|
| [pigeon](./packages/pigeon/) | [](https://pub.dev/packages/pigeon) |
|
||||||
|
| [pointer_interceptor](./packages/pointer_interceptor/) | [](https://pub.dev/packages/pointer_interceptor) |
|
||||||
| [xdg_directories](./packages/xdg_directories/) | [](https://pub.dev/packages/xdg_directories) |
|
| [xdg_directories](./packages/xdg_directories/) | [](https://pub.dev/packages/xdg_directories) |
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
## 0.9.0
|
||||||
|
|
||||||
|
* Migrates to null safety.
|
||||||
|
|
||||||
## 0.8.0+2
|
## 0.8.0+2
|
||||||
|
|
||||||
* Use `ElevatedButton` instead of the deprecated `RaisedButton` in example and docs.
|
* Use `ElevatedButton` instead of the deprecated `RaisedButton` in example and docs.
|
||||||
|
@ -8,7 +8,7 @@ An example for the PointerInterceptor widget.
|
|||||||
|
|
||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
`flutter drive --target integration_test/widget_test.dart --driver test_driver/integration_test.dart --show-web-server-device -d web-server`
|
`flutter drive --target integration_test/widget_test.dart --driver test_driver/integration_test.dart --show-web-server-device -d web-server --web-renderer=html`
|
||||||
|
|
||||||
The command above will run the integration tests for this package.
|
The command above will run the integration tests for this package.
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.9
|
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
|
|
||||||
// Imports the Flutter Driver API.
|
// Imports the Flutter Driver API.
|
||||||
@ -27,12 +26,12 @@ void main() {
|
|||||||
app.main();
|
app.main();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
final html.Element element =
|
final html.Element? element =
|
||||||
_getHtmlElementFromFinder(clickableButtonFinder, tester);
|
_getHtmlElementFromFinder(clickableButtonFinder, tester);
|
||||||
expect(element.tagName.toLowerCase(), 'flt-platform-view');
|
expect(element?.tagName.toLowerCase(), 'flt-platform-view');
|
||||||
|
|
||||||
final html.Element platformViewRoot =
|
final html.Element? platformViewRoot =
|
||||||
element.shadowRoot.getElementById('background-html-view');
|
element?.shadowRoot?.getElementById('background-html-view');
|
||||||
expect(platformViewRoot, isNull);
|
expect(platformViewRoot, isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,12 +41,12 @@ void main() {
|
|||||||
app.main();
|
app.main();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
final html.Element element =
|
final html.Element? element =
|
||||||
_getHtmlElementFromFinder(nonClickableButtonFinder, tester);
|
_getHtmlElementFromFinder(nonClickableButtonFinder, tester);
|
||||||
expect(element.tagName.toLowerCase(), 'flt-platform-view');
|
expect(element?.tagName.toLowerCase(), 'flt-platform-view');
|
||||||
|
|
||||||
final html.Element platformViewRoot =
|
final html.Element? platformViewRoot =
|
||||||
element.shadowRoot.getElementById('background-html-view');
|
element?.shadowRoot?.getElementById('background-html-view');
|
||||||
expect(platformViewRoot, isNotNull);
|
expect(platformViewRoot, isNotNull);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -56,7 +55,7 @@ void main() {
|
|||||||
// This functions locates a widget from a Finder, and asks the browser what's the
|
// This functions locates a widget from a Finder, and asks the browser what's the
|
||||||
// DOM element in the center of the coordinates of the widget. (Returns *which*
|
// DOM element in the center of the coordinates of the widget. (Returns *which*
|
||||||
// DOM element will handle Mouse interactions first at those coordinates.)
|
// DOM element will handle Mouse interactions first at those coordinates.)
|
||||||
html.Element _getHtmlElementFromFinder(Finder finder, WidgetTester tester) {
|
html.Element? _getHtmlElementFromFinder(Finder finder, WidgetTester tester) {
|
||||||
final Offset point = tester.getCenter(finder);
|
final Offset point = tester.getCenter(finder);
|
||||||
return html.document.elementFromPoint(point.dx.toInt(), point.dy.toInt());
|
return html.document.elementFromPoint(point.dx.toInt(), point.dy.toInt());
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
/// Initialize the videoPlayer, then render the corresponding view...
|
/// Initialize the videoPlayer, then render the corresponding view...
|
||||||
class HtmlElement extends StatelessWidget {
|
class HtmlElement extends StatelessWidget {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
const HtmlElement({this.onClick});
|
const HtmlElement({required this.onClick});
|
||||||
|
|
||||||
/// A function to run when the element is clicked
|
/// A function to run when the element is clicked
|
||||||
final Function onClick;
|
final Function onClick;
|
||||||
|
@ -22,7 +22,7 @@ class webOnlyAssetManager {
|
|||||||
/// Shim for getAssetUrl.
|
/// Shim for getAssetUrl.
|
||||||
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
|
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
|
||||||
static String getAssetUrl(String asset) {
|
static String getAssetUrl(String asset) {
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ publish_to: 'none'
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.12.0-0 <3.0.0"
|
||||||
|
flutter: ">=1.26.0-0" # For integration_test from sdk
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -8,9 +8,9 @@ import 'package:flutter/widgets.dart';
|
|||||||
class PointerInterceptor extends StatelessWidget {
|
class PointerInterceptor extends StatelessWidget {
|
||||||
/// Create a `PointerInterceptor` wrapping a `child`.
|
/// Create a `PointerInterceptor` wrapping a `child`.
|
||||||
const PointerInterceptor({
|
const PointerInterceptor({
|
||||||
@required this.child,
|
required this.child,
|
||||||
this.debug = false,
|
this.debug = false,
|
||||||
Key key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The `Widget` that is being wrapped by this `PointerInterceptor`.
|
/// The `Widget` that is being wrapped by this `PointerInterceptor`.
|
||||||
|
@ -22,7 +22,7 @@ class webOnlyAssetManager {
|
|||||||
/// Shim for getAssetUrl.
|
/// Shim for getAssetUrl.
|
||||||
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
|
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
|
||||||
static String getAssetUrl(String asset) {
|
static String getAssetUrl(String asset) {
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ void _registerFactory({bool debug = false}) {
|
|||||||
class PointerInterceptor extends StatelessWidget {
|
class PointerInterceptor extends StatelessWidget {
|
||||||
/// Creates a PointerInterceptor for the web.
|
/// Creates a PointerInterceptor for the web.
|
||||||
PointerInterceptor({
|
PointerInterceptor({
|
||||||
@required this.child,
|
required this.child,
|
||||||
this.debug = false,
|
this.debug = false,
|
||||||
Key key,
|
Key? key,
|
||||||
}) : super(key: key) {
|
}) : super(key: key) {
|
||||||
if (!_registered) {
|
if (!_registered) {
|
||||||
_register();
|
_register();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
name: pointer_interceptor
|
name: pointer_interceptor
|
||||||
description: A widget to prevent clicks from being swallowed by underlying HtmlElementViews on the web.
|
description: A widget to prevent clicks from being swallowed by underlying HtmlElementViews on the web.
|
||||||
version: 0.8.0+2
|
|
||||||
repository: https://github.com/flutter/packages
|
repository: https://github.com/flutter/packages
|
||||||
|
version: 0.9.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.12.0-0 <3.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Reference in New Issue
Block a user