For instance we have a like
button that when the user press it, it will call an http function somewhere in the cloud.
FlatButton(
onPressed: () => callOnLikeFunction(),
);
What if the user pressed it multiple times (like and unlike over and over)? Then it will call the http function many times and can cause errors.
So I tried using
Future.delayed(Duration(seconds: 2)).then(() =>
callOnLikeFunction()
);
But this does not work because it will still fire as many times as pressed, just delayed.
So the question is how do we wait until the last press as the final decision of the user and ignore the other attempts?
Update: Defining the last tap: Suppose a user taps 3x with 500ms interval but the 3rd tap stands the test of time of 2seconds then the 3rd tap is considered the last tap