I want to disable all the functionality related to copy, paste and select all on the press of textformfield
in the flutter. I have a password field which can take keyboard hint and able to paste data by default but when I perform the operation like calling login service then password field gone wrong.
TextFormField(
obscureText: true,
style: styleText,
textInputAction: TextInputAction.done,
controller: _passwordController,
focusNode: _passwordFocus,
onFieldSubmitted: (term){
_passwordFocus.unfocus();
},
keyboardType: TextInputType.text,
validator: validatePassword,
decoration: InputDecoration(
focusedBorder: border,
border: border,
enabledBorder: border,
hintStyle: styleText,
hintText: 'Password'),
onSaved: (String val) {
_password = val;
},
),
To create a TextFormField in Flutter, Flutter provides a TextFormField () widget. You can style it according to your needs. A simple and without any style underline TextFormField is below. To handle user input in TextFormField, create an object of TextEditingController class.
) TextField and TextFormField both have an argument called enabled. You can control it using a boolean variable. enabled=true means it will act as an editing text field whereas enabled=false will Disable the TextField Widget. Create AlwaysDisabledFocusNode and pass it to the focusNode property of a TextField Widget .
TextFormField widget is used to take input from the user in flutter. This is a simple and easy user input widget in flutter. We can perform any operation on that user input data using TextFormField. You can use that user input, can send and show that input.
Create a method in MyFormState, that will generate the list of friend text fields according to the length of friendsList. The last row of the friend text field will have add button and rest all the rows will have remove button with them.
You can use the enableinteractiveSelection : false
to Disable the copy/paste.
TextFormField(
enableInteractiveSelection: false,
obscureText: true,
style: styleText,
textInputAction: TextInputAction.done,
controller: _passwordController,
focusNode: _passwordFocus,
onFieldSubmitted: (term){
_passwordFocus.unfocus();
},
keyboardType: TextInputType.text,
validator: validatePassword,
decoration: InputDecoration(
focusedBorder: border,
border: border,
enabledBorder: border,
hintStyle: styleText,
hintText: 'Password'),
onSaved: (String val) {
_password = val;
},
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With