I am searching for a function in flutter (web) that can detect the amount of pressure tap force on the screen. Any help?
Asked
Active
Viewed 313 times
1
-
see https://api.flutter.dev/flutter/gestures/PointerEvent/pressure.html and/or https://api.flutter.dev/flutter/gestures/ForcePressGestureRecognizer-class.html – pskink Jan 18 '22 at 10:56
-
Hello, I have used the pressure property in the PointerEvent Class but it is always returning the value 1.0, I think I am using it in a wrong way. Please if you can send me an example of the implementation. – Abed Baltaji Jan 19 '22 at 13:48
-
the docs i sent in my first comment say: *"This value is a number ranging from 0.0, indicating a touch with no discernible pressure, to 1.0, indicating a touch with "normal" pressure, and possibly beyond, indicating a stronger touch. For devices that do not detect pressure (e.g. mice), returns 1.0."* - notice the last sentence – pskink Jan 19 '22 at 13:59
-
GestureDetector (https://api.flutter.dev/flutter/widgets/GestureDetector-class.html )class has onForcePressUpdate and other methods using which you can measure force applied on the screen. I tested the flutter app on iphone and it worked fine but, when I tried to build a webapp and tested it on safari browser then it didn't work. – Rahul Sahni Mar 04 '22 at 01:29
-
Can you please send an example for the implementation @RahulSahni – Abed Baltaji Mar 09 '22 at 16:47
-
@AbedBaltaji Use GestureDetector as a widget like this. GestureDetector( onForcePressUpdate: (ForcePressDetails details) { print("onForcePressUpdate: ${details.pressure}"); }, child: const Padding(padding: EdgeInsets.all(16.0), child: Text( 'PRESS' ), ), ) – Rahul Sahni Mar 11 '22 at 16:08
-
@RahulSahni Which iPhone model did you used when it worked with you? Because I've read that there is specific models of iPhone that support pressure detection. – Abed Baltaji Mar 13 '22 at 09:05
-
@AbedBaltaji iPhone 6s, iPhone 6s Plus, iPhone 7, iPhone 7 Plus, iPhone 8, iPhone 8 Plus, iPhone X, iPhone XS, and iPhone XS Max. Only these devices have force touch – Rahul Sahni Mar 13 '22 at 18:43
-
@RahulSahni did find a solution for the forcePressDetection in a flutter webapp? Or you have any other suggestions. – Abed Baltaji Apr 05 '22 at 09:41
-
@AbedBaltaji I ended up using React for my use-case because I couldn't figure it out – Rahul Sahni Apr 06 '22 at 21:52