-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long press stop sending gesture callbacks #25610
Comments
Looks related to #11385 |
I'm facing the same problem. And that's a bit disappointing. Considering the description for It seems like when This is my code if it can be helpful. A long press changes the color of the box and canceling it reverts it back. import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: "Markdown Demo",
theme: ThemeData(primarySwatch: Colors.lightGreen),
home: HomePage(),
),
);
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Color myColor = Colors.lightBlueAccent;
Widget _buildtest() {
_longPressUp() {
setState(() {
myColor = Colors.lightBlueAccent;
});
print('-- Back to main color');
}
return Center(
child: Container(
color: myColor,
width: 300,
height: 300,
child: GestureDetector(
onTap: () {},
onTapUp: (_) {
print('onTap Up');
_longPressUp();
},
onLongPress: () {
print('LongPress');
print('-> Changing Color');
setState(() {
myColor = Colors.limeAccent;
});
},
onLongPressUp: () {
print('LongPress Up');
_longPressUp();
},
// ---> Either use onPan or onScale
// onScaleEnd: (_) {
// print('Scale End');
// _longPressUp();
// },
// for checking when an onScale is detected
// onScaleStart: (details) {
// print('Scale Started: $details');
// },
onPanEnd: (_) {
print('Pan End');
_longPressUp();
},
// for checking when an onPan is detected
onPanStart: (details) {
print('Pan Started: $details');
},
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Long press Up detection',
style: TextStyle(
color: Colors.white,
),
),
),
body: _buildtest(),
);
}
} |
We're talking about this behavior right?
It should work. If you move before a long press is recognized, it's by definition not a long press :D
|
Any updates on this? I really need an option to show a widget on long press and then hide it when they release |
I can not detect I'd say the |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
I can not detect any gesture events when the user moves the finger during a long press.
I run some code while the user make a long press on a button and detect when it's finishes.
As long as the finger does not move around everything works well as the widget receives the expected callbacks : onLongPress & onLongPressUp.
However, if the user moves the finger while doing the long press, there won't be any other future callback at all.
Sample app: main.dart
If the finger doesn't reach the widget borders I'd expect the onLongPressUp when the finger is up.
If the finger gets out of the widget layout I'd expect the widget to keep listening the gesture events OR receive a onLongPressCanceled callback
The text was updated successfully, but these errors were encountered: