2024-03-18 13:23:58 +08:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
|
|
class TapToDismissKeyboard extends StatelessWidget {
|
|
|
|
final Widget? child;
|
2024-03-20 10:37:52 +08:00
|
|
|
final BuildContext context;
|
|
|
|
const TapToDismissKeyboard({super.key, this.child, required this.context});
|
2024-03-18 13:23:58 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
TapToDismissKeyboard.dismissOf(context: context);
|
|
|
|
},
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static dismissOf({required BuildContext context}) {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
}
|
|
|
|
}
|