I am getting a range error in textfield when i remove all the elements form the textflield in my flutter code

Advertisements I am facing an error when i use backspace to remove all the content in the textfield.The error that i am getting is this: The following RangeError was thrown while handling a gesture: RangeError (end): Invalid value: Only valid value is 0: -1 and is there a way by which the "Rs." string remains… Read More I am getting a range error in textfield when i remove all the elements form the textflield in my flutter code

TextFormFied validate spacing

Advertisements I have TextFormField widget with username TextFormField( controller: usernameController, validator: (value) { if (value!.isEmpty) { return ‘username is empty’; } if (value.length <= 4) { return ‘passord id too short, min 4 characters’; } return null; }, decoration: const InputDecoration( hintText: ‘username’, border: OutlineInputBorder( borderSide: BorderSide(color: Colors.black))), ), But I want to take username… Read More TextFormFied validate spacing

Form validation in flutter passes despite not meeting conditions

Advertisements I am building a Flutter application with multiple TextFormFields. I create a reusable TextFormfield Widget to keep things modular. The problem is, when the submit button is clicked, even though the Text Form Fields are not valid, it runs like it is valid. My TextFormField widget: class AndroidTextField extends StatelessWidget { final ValueChanged<String> onChanged;… Read More Form validation in flutter passes despite not meeting conditions

Validate TextFormField from another class

Advertisements I have 2 statefull class, first class contains TextFormField and button to validate the TextFormField. And the second class contains TextFormField. How to validate second TextFormField thats called in first class when tap the button? class FormValidation extends StatefulWidget { const FormValidation({Key key}) : super(key: key); @override _FormValidationState createState() => _FormValidationState(); } class _FormValidationState… Read More Validate TextFormField from another class

Automatically resize Flutter TextFormField content as the user is typing while keeping maxLines equal to 1

Advertisements I am using TextFormField in my Flutter app to get the email address of users. Some email addresses are long and so, if I keep typing, it will go out of the box. See how the first few letters of the email in the image below are outside the box. Below is the code… Read More Automatically resize Flutter TextFormField content as the user is typing while keeping maxLines equal to 1