I need to display the mask and ignore the events of other widgets when the mask is displayed. When I remove onDoubleTap or IgnorePointer, the onTap method calls back in a very quick instant. But if I use onDoubleTap and IgnorePointer at the same time, the onTap callback of the mask has a visible delay. What am I doing wrong and how can I fix it?
Sample
import 'package:flutter/gestures.dart';
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: 'Tests',
home: const MyHomePage(),
debugShowCheckedModeBanner: false,
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: PointerDeviceKind.values.toSet(),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _visible = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home')),
body: Stack(children: [
GestureDetector(
onDoubleTap: () {},
child: ListView(
children: List.generate(100, (i) {
return ListTile(title: Text('Item $i'));
}),
),
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 300),
child: IgnorePointer(
ignoring: !_visible,
child: Container(color: Colors.blue.withOpacity(0.8)),
),
),
GestureDetector(onTap: () => setState(() => _visible = !_visible)),
]),
);
}
}
Logs
Logs
Analyzing fluttest...
No issues found! (ran in 1.2s)
[!] Flutter (Channel unknown, 3.3.3, on Microsoft Windows [版本 10.0.19044.2604], locale zh-CN)
! Flutter version 3.3.3 on channel unknown at D:\***\flutter
! Upstream repository unknown
• Framework revision 18a827f393 (5 months ago), 2022-09-28 10:03:14 -0700
• Engine revision 5c984c26eb
• Dart version 2.18.2
• DevTools version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\***\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.18)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.32802.440
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• 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)
[√] VS Code, 64-bit edition (version 1.69.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.19044.2604]
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.178
• Edge (web) • edge • web-javascript • Microsoft Edge 108.0.1462.54
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
I need to display the mask and ignore the events of other widgets when the mask is displayed. When I remove
onDoubleTaporIgnorePointer, theonTapmethod calls back in a very quick instant. But if I useonDoubleTapandIgnorePointerat the same time, theonTapcallback of the mask has a visible delay. What am I doing wrong and how can I fix it?Sample
Logs
Logs