flutter trigger show off keyboard
FocusScope.of(context).unfocus()
flutter trigger show off keyboard
FocusScope.of(context).unfocus()
remove focus textfield flutter
// main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
),
);
}
}
how i can close keyboard in flutter
class YourPage extends StatefulWidget {
createState() => _YourPageState();
}
class _YourPageState extends State<MobileHome> {
FocusNode focusNode = new FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextField(
focusNode: focusNode,
),
SizedBox(height: 10,),
RaisedButton(child: Text("UP"),onPressed: (){
FocusScope.of(context).requestFocus(focusNode);
},),
SizedBox(height: 10,),
RaisedButton(child: Text("DOWN"),onPressed: (){
focusNode.unfocus();
},),
],
)
);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us