tapTarget static method

Widget tapTarget({
  1. required Widget child,
  2. Key? key,
})

A convenience widget that wraps any child with PointerInterceptor

Use this to wrap buttons or other interactive widgets that are stacked on top of SWebView in a Stack. This ensures they receive pointer events on Flutter Web where WebView iframes capture all events.

Example:

Stack(
  children: [
    SWebView(url: 'https://flutter.dev'),
    Positioned(
      top: 100,
      right: 100,
      child: SWebView.tapTarget(
        child: ElevatedButton(
          onPressed: () => print('Tapped!'),
          child: Text('Tap me'),
        ),
      ),
    ),
  ],
)

Implementation

static Widget tapTarget({
  required Widget child,
  Key? key,
}) {
  if (kIsWeb) {
    return PointerInterceptor(
      key: key,
      child: child,
    );
  }
  return child;
}