Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

close keyboard on button click flutter

class _HomeState extends State<Home> {
 var currentFocus;
    
 unfocus() {
    currentFocus = FocusScope.of(context);

    if (!currentFocus.hasPrimaryFocus) {
      currentFocus.unfocus();
    }
  }
  
Widget build(BuildContext context) {
    return GestureDetector(
      onTap: unfocus,
      child: Scaffold(...)
      )
     }
Source by flutterigniter.com #
 
PREVIOUS NEXT
Tagged: #close #keyboard #button #click #flutter
ADD COMMENT
Topic
Name
1+5 =