23 lines
515 B
Dart
23 lines
515 B
Dart
import 'package:flutter/cupertino.dart';
|
|
|
|
class TapToDismissKeyboard extends StatelessWidget {
|
|
final Widget? child;
|
|
late BuildContext context;
|
|
|
|
TapToDismissKeyboard({this.child, required 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());
|
|
}
|
|
}
|