onTapRecognizeGesture method
Sets up a tap gesture recognizer for the onTapRecognizeGesture method.
This method creates a tap gesture recognizer and attaches an onTap action to it. When the gesture is recognized, it navigates to the specified route with optional args.
Implementation
TapGestureRecognizer onTapRecognizeGesture(
{String? routeName, Map<String,dynamic>? args}) {
void onTap() {
if (routeName != null) {
// Navigates to the specified route with optional args.
Navigator.of(context).pushNamed(routeName, arguments: args);
}
}
// Attach the onTap action to the recognizer.
// Create a TapGestureRecognizer and attach the onTap action to it.
TapGestureRecognizer gestureRecognizer = TapGestureRecognizer()
..onTap = onTap;
return gestureRecognizer;
}