tappable<R> function
Widget
tappable<R>(
- Widget child, {
- FutureOrTappableCallback? onTap,
- Key? key,
- double pressOpacity = 1.0,
- BuildContext? context,
- String? routeName,
- dynamic arguments,
- void callback(
- R? result
Enforces HitTest.opaque and removes parameters
Implementation
Widget tappable<R>(Widget child,
{FutureOrTappableCallback? onTap,
Key? key,
double pressOpacity = 1.0,
BuildContext? context,
String? routeName,
arguments,
void callback(R? result)?}) {
if (onTap == null && routeName == null) return child;
return GestureDetector(
child: child,
onTap: () async {
onTap?.call();
assert(routeName == null || context != null,
"If you provide a route, you must also provide a buildContext");
if (routeName != null) {
final R? result = await Navigator.pushNamed(context!, routeName,
arguments: arguments);
callback!(result);
}
},
behavior: HitTestBehavior.opaque);
}