I'm trying to use the onForcePress properties, e.g. onForcePressStart, onForcePressUpdate etc, of the GestureDetector widget in Flutter, but they are not triggering their callbacks when I touch the screen (as lightly as I can or as forcefully as I dare). I previously implemented my otherwise identical code with onPanStart, onPanUpdate etc, and it worked as expected, just without access to the pressure information I desire.
Minimal working example where the GestureForcePress callbacks don't seem to be called:
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
print('onTap triggered');
},
// onPanStart: (details) {
// print('onPanStart triggered with ' + details.toString());
// },
// onPanUpdate: (details) {
// print('onPanUpdate triggered with ' + details.toString());
// },
onForcePressStart: (details) {
print('onForcePressStart triggered with ' + details.toString());
},
onForcePressUpdate: (details) {
print('onForcePressUpdate triggered with ' + details.toString());
},
child: Container(
color: Colors.red,
),
);
}
}
I'm aware they shouldn't trigger if pressure is less than startPressure, which is 0.4 on a 0 to 1 scale by default for the GestureDetector widget. (I'd also like to know how to edit this startPressure property, but will ask that as a separate question.)
The device I'm testing this on is a Galaxy Note 10+ that readily gives pressure information to other apps.