I used shake 2.2.0 from pub.dev to detect when a phone shake ! and it works, when the user shakes the phone an alertdialog pops up
the thing is after it's up the user still can shake the phone and another alertdialog shows up, i want the shake to stop taking effects when the alertdialog is up and to go back detecting when it's dismissed ! as you can see i tried a bool isSuportDialogOpen so it stops listening when it is ... but it doesn't work
detector = ShakeDetector.waitForStart(
onPhoneShake: () {
return AlertDialog(
title: const Text('Help'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('Help.'),
Text('Do you need some help?'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('discard'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
log('phone is shaking');
setState(() {
isSuportDialogOpen = true;
});
},
);
if (!isSuportDialogOpen) {
setState(() {
detector.startListening();
});
}
if (isSuportDialogOpen) {
setState(() {
detector.stopListening();
});
}