Skip to content

TapRegion should support HitTestBehavior #112924

@likang

Description

@likang

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. click on the blank area (which is inside TapRegion, see inspector screenshot bellow)

Expected results:
call onTapInside, change text to "taped inside!"

Actual results:
nothing happened

Suggestions:

  • add an argument to TapRegion to allow opaque behavior just like Listener
Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TapRegion Demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('TapRegion Demo'),
        ),
        body: const TapRegionDemo(),
      ),
    );
  }
}

class TapRegionDemo extends StatefulWidget {
  const TapRegionDemo({Key? key}) : super(key: key);

  @override
  State<TapRegionDemo> createState() => _TapRegionDemoState();
}

class _TapRegionDemoState extends State<TapRegionDemo> {
  String text = "tap the blank area (which is also in TapRegion area)";
  @override
  Widget build(BuildContext context) {
    return TapRegion(
      onTapInside: (e){
        setState(() {
          text = "taped inside!";
        });
      },
      child: Stack(
        children: [
          Positioned(left: 0, top:0, child: Text(text)),
        ],
      ),
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel beta, 3.4.0-17.2.pre, on macOS 12.4 21F79 darwin-arm, locale zh-Hans-CN)
    • Flutter version 3.4.0-17.2.pre on channel beta at /Users/likang/SDKs/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d6260f127f (13 days ago), 2022-09-21 13:33:49 -0500
    • Engine revision 3950c6140a
    • Dart version 2.19.0 (build 2.19.0-146.2.beta)
    • DevTools version 2.16.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/likang/SDKs/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Connected device (1 available)
    • macOS (desktop) • macos • darwin-arm64 • macOS 12.4 21F79 darwin-arm

ss2022-10-05 15 43 08

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions