mobile_skt/lib/widgets/tap_to_dismiss_keyboard.dart

22 lines
537 B
Dart
Raw Permalink Normal View History

2024-10-16 09:48:17 +08:00
import 'package:flutter/cupertino.dart';
class TapToDismissKeyboard extends StatelessWidget {
final Widget? child;
final BuildContext context;
const TapToDismissKeyboard({super.key, this.child, required this.context});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
TapToDismissKeyboard.dismissOf(context: context);
},
child: child,
);
}
static dismissOf({required BuildContext context}) {
FocusScope.of(context).requestFocus(FocusNode());
}
}