Skip to content

Commit

Permalink
Clean imports, make onElementCreated a tear-off
Browse files Browse the repository at this point in the history
  • Loading branch information
ditman committed Jan 3, 2024
1 parent 48d6b98 commit 9ab2360
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'package:pointer_interceptor_web_example/main.dart' as app;

import 'package:web/web.dart' as web;

final Finder nonClickableButtonFinder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dart:ui_web' as ui_web;
import 'package:flutter/material.dart';
import 'package:pointer_interceptor_platform_interface/pointer_interceptor_platform_interface.dart';
import 'package:pointer_interceptor_web/pointer_interceptor_web.dart';

import 'package:web/web.dart' as web;

const String _htmlElementViewType = '_htmlElementViewType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import 'package:flutter/widgets.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';

import 'package:pointer_interceptor_platform_interface/pointer_interceptor_platform_interface.dart';

import 'package:web/web.dart' as web;

/// The web implementation of the `PointerInterceptor` widget.
Expand All @@ -18,6 +16,11 @@ class PointerInterceptorWeb extends PointerInterceptorPlatform {
PointerInterceptorPlatform.instance = PointerInterceptorWeb();
}

// Slightly modify the created `element` (for `debug` mode).
void _onElementCreated(Object element) {
(element as web.HTMLElement).style.backgroundColor = 'rgba(255, 0, 0, .5)';
}

@override
Widget buildWidget({
required Widget child,
Expand All @@ -35,12 +38,7 @@ class PointerInterceptorWeb extends PointerInterceptorPlatform {
child: HtmlElementView.fromTagName(
tagName: 'div',
isVisible: false,
onElementCreated: debug
? (Object element) {
element as web.HTMLElement;
element.style.backgroundColor = 'rgba(255, 0, 0, .5)';
}
: null,
onElementCreated: debug ? _onElementCreated : null,
),
),
child,
Expand Down

0 comments on commit 9ab2360

Please sign in to comment.