Improve form validation

This commit is contained in:
Hillel Coren 2022-10-02 12:16:45 +03:00
parent c77964b7f1
commit de91df3af9
18 changed files with 4 additions and 107 deletions

View File

@ -15,7 +15,6 @@ class DecoratedFormField extends StatefulWidget {
this.controller, this.controller,
this.label, this.label,
this.onSavePressed, this.onSavePressed,
this.autovalidate = false,
this.autocorrect = false, this.autocorrect = false,
this.obscureText = false, this.obscureText = false,
this.onChanged, this.onChanged,
@ -48,7 +47,6 @@ class DecoratedFormField extends StatefulWidget {
final TextInputType keyboardType; final TextInputType keyboardType;
final int maxLines; final int maxLines;
final int minLines; final int minLines;
final bool autovalidate;
final bool enabled; final bool enabled;
final bool autocorrect; final bool autocorrect;
final bool obscureText; final bool obscureText;
@ -140,13 +138,11 @@ class _DecoratedFormFieldState extends State<DecoratedFormField> {
autofocus: widget.autofocus, autofocus: widget.autofocus,
decoration: inputDecoration, decoration: inputDecoration,
validator: widget.validator, validator: widget.validator,
autovalidateMode: AutovalidateMode.onUserInteraction,
keyboardType: widget.keyboardType, keyboardType: widget.keyboardType,
maxLines: widget.expands ? null : widget.maxLines ?? 1, maxLines: widget.expands ? null : widget.maxLines ?? 1,
minLines: widget.expands ? null : widget.minLines, minLines: widget.expands ? null : widget.minLines,
expands: widget.expands, expands: widget.expands,
autovalidateMode: widget.autovalidate
? AutovalidateMode.onUserInteraction
: AutovalidateMode.disabled,
autocorrect: autocorrect:
widget.isMoney || widget.isPercent ? false : widget.autocorrect, widget.isMoney || widget.isPercent ? false : widget.autocorrect,
obscureText: widget.obscureText, obscureText: widget.obscureText,

View File

@ -8,7 +8,6 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class PasswordFormField extends StatefulWidget { class PasswordFormField extends StatefulWidget {
const PasswordFormField({ const PasswordFormField({
this.controller, this.controller,
this.autoValidate,
this.newPassword = true, this.newPassword = true,
this.validate = true, this.validate = true,
this.onSavePressed, this.onSavePressed,
@ -17,7 +16,6 @@ class PasswordFormField extends StatefulWidget {
final TextEditingController controller; final TextEditingController controller;
final Function(BuildContext) onSavePressed; final Function(BuildContext) onSavePressed;
final bool autoValidate;
final bool newPassword; final bool newPassword;
final bool validate; final bool validate;
final String labelText; final String labelText;
@ -44,7 +42,6 @@ class _PasswordFormFieldState extends State<PasswordFormField> {
controller: widget.controller, controller: widget.controller,
onSavePressed: widget.onSavePressed, onSavePressed: widget.onSavePressed,
autocorrect: false, autocorrect: false,
autovalidate: widget.autoValidate,
decoration: InputDecoration( decoration: InputDecoration(
labelText: widget.labelText ?? localization.password, labelText: widget.labelText ?? localization.password,
suffixIcon: IconButton( suffixIcon: IconButton(

View File

@ -77,7 +77,6 @@ class _LoginState extends State<LoginView> {
bool _createAccount = false; bool _createAccount = false;
bool _recoverPassword = false; bool _recoverPassword = false;
bool _autoValidate = false;
bool _termsChecked = false; bool _termsChecked = false;
bool _privacyChecked = false; bool _privacyChecked = false;
@ -157,7 +156,6 @@ class _LoginState extends State<LoginView> {
: kAppProductionUrl; : kAppProductionUrl;
setState(() { setState(() {
_autoValidate = !isValid ?? false;
_loginError = ''; _loginError = '';
}); });
@ -223,7 +221,6 @@ class _LoginState extends State<LoginView> {
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
setState(() { setState(() {
_autoValidate = !isValid ?? false;
_loginError = ''; _loginError = '';
}); });
@ -428,7 +425,6 @@ class _LoginState extends State<LoginView> {
controller: _emailController, controller: _emailController,
label: localization.email, label: localization.email,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
autovalidate: _autoValidate,
validator: (val) => validator: (val) =>
val.isEmpty || val.trim().isEmpty val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterYourEmail ? localization.pleaseEnterYourEmail
@ -441,7 +437,6 @@ class _LoginState extends State<LoginView> {
!_recoverPassword) !_recoverPassword)
PasswordFormField( PasswordFormField(
controller: _passwordController, controller: _passwordController,
autoValidate: false,
newPassword: _createAccount, newPassword: _createAccount,
onSavePressed: (_) => _submitForm(), onSavePressed: (_) => _submitForm(),
), ),
@ -470,7 +465,6 @@ class _LoginState extends State<LoginView> {
labelText: labelText:
'${localization.secret} (${localization.optional})', '${localization.secret} (${localization.optional})',
controller: _secretController, controller: _secretController,
autoValidate: _autoValidate,
validate: false, validate: false,
onSavePressed: (_) => _submitForm(), onSavePressed: (_) => _submitForm(),
), ),

View File

@ -27,7 +27,6 @@ class _BankAccountEditState extends State<BankAccountEdit> {
static final GlobalKey<FormState> _formKey = static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_bankAccountEdit'); GlobalKey<FormState>(debugLabel: '_bankAccountEdit');
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
bool _autoValidate = false;
final _nameController = TextEditingController(); final _nameController = TextEditingController();
@ -88,10 +87,6 @@ class _BankAccountEditState extends State<BankAccountEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -115,7 +110,6 @@ class _BankAccountEditState extends State<BankAccountEdit> {
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAName ? localization.pleaseEnterAName
: null, : null,
autovalidate: _autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
), ),

View File

@ -251,12 +251,6 @@ class _DesignEditState extends State<DesignEdit>
: (context) { : (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
/*
setState(() {
_autoValidate = !isValid;
});
*/
if (!isValid) { if (!isValid) {
return; return;
} }
@ -458,6 +452,8 @@ class _DesignSettingsState extends State<DesignSettings> {
label: localization.name, label: localization.name,
controller: widget.nameController, controller: widget.nameController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
validator: (value) =>
value.isEmpty ? localization.pleaseEnterAName : null,
), ),
DesignPicker( DesignPicker(
label: localization.design, label: localization.design,

View File

@ -27,7 +27,6 @@ class _ExpenseCategoryEditState extends State<ExpenseCategoryEdit> {
static final GlobalKey<FormState> _formKey = static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_expenseCategoryEdit'); GlobalKey<FormState>(debugLabel: '_expenseCategoryEdit');
final _debouncer = Debouncer(); final _debouncer = Debouncer();
bool _autoValidate = false;
// STARTER: controllers - do not remove comment // STARTER: controllers - do not remove comment
final _nameController = TextEditingController(); final _nameController = TextEditingController();
@ -86,10 +85,6 @@ class _ExpenseCategoryEditState extends State<ExpenseCategoryEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -107,7 +102,6 @@ class _ExpenseCategoryEditState extends State<ExpenseCategoryEdit> {
DecoratedFormField( DecoratedFormField(
autofocus: true, autofocus: true,
controller: _nameController, controller: _nameController,
autovalidate: _autoValidate,
label: localization.name, label: localization.name,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,

View File

@ -32,7 +32,6 @@ class _GroupEditState extends State<GroupEdit> {
List<TextEditingController> _controllers = []; List<TextEditingController> _controllers = [];
final _debouncer = Debouncer(); final _debouncer = Debouncer();
bool autoValidate = false;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
@ -85,10 +84,6 @@ class _GroupEditState extends State<GroupEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
autoValidate = !isValid ?? false;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -112,7 +107,6 @@ class _GroupEditState extends State<GroupEdit> {
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAValue ? localization.pleaseEnterAValue
: null, : null,
autovalidate: autoValidate,
), ),
], ],
), ),

View File

@ -32,7 +32,6 @@ class _ProductEditState extends State<ProductEdit> {
static final GlobalKey<FormState> _formKey = static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_productEdit'); GlobalKey<FormState>(debugLabel: '_productEdit');
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
bool _autoValidate = false;
final _productKeyController = TextEditingController(); final _productKeyController = TextEditingController();
final _notesController = TextEditingController(); final _notesController = TextEditingController();
@ -149,10 +148,6 @@ class _ProductEditState extends State<ProductEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -175,7 +170,6 @@ class _ProductEditState extends State<ProductEdit> {
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAProductKey ? localization.pleaseEnterAProductKey
: null, : null,
autovalidate: _autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
), ),

View File

@ -35,8 +35,6 @@ class _ProjectEditState extends State<ProjectEdit> {
GlobalKey<FormState>(debugLabel: '_projectEdit'); GlobalKey<FormState>(debugLabel: '_projectEdit');
final _debouncer = Debouncer(); final _debouncer = Debouncer();
bool _autoValidate = false;
final _numberController = TextEditingController(); final _numberController = TextEditingController();
final _nameController = TextEditingController(); final _nameController = TextEditingController();
final _dueDateController = TextEditingController(); final _dueDateController = TextEditingController();
@ -132,10 +130,6 @@ class _ProjectEditState extends State<ProjectEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -156,7 +150,6 @@ class _ProjectEditState extends State<ProjectEdit> {
validator: (String val) => val.trim().isEmpty validator: (String val) => val.trim().isEmpty
? localization.pleaseEnterAName ? localization.pleaseEnterAName
: null, : null,
autovalidate: _autoValidate,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
autofocus: true, autofocus: true,
label: localization.projectName, label: localization.projectName,
@ -175,7 +168,6 @@ class _ProjectEditState extends State<ProjectEdit> {
validator: (String val) => val.trim().isEmpty validator: (String val) => val.trim().isEmpty
? localization.pleaseSelectAClient ? localization.pleaseSelectAClient
: null, : null,
autoValidate: _autoValidate,
onSelected: (client) { onSelected: (client) {
viewModel.onChanged(project.rebuild( viewModel.onChanged(project.rebuild(
(b) => b..clientId = client?.id ?? '')); (b) => b..clientId = client?.id ?? ''));

View File

@ -53,7 +53,6 @@ class _ClientPortalState extends State<ClientPortal>
TabController _controller; TabController _controller;
final _webClient = WebClient(); final _webClient = WebClient();
bool _autoValidate = false;
bool _isSubdomainUnique = true; bool _isSubdomainUnique = true;
bool _isCheckingSubdomain = false; bool _isCheckingSubdomain = false;
@ -218,10 +217,6 @@ class _ClientPortalState extends State<ClientPortal>
void _onSavePressed(BuildContext context) { void _onSavePressed(BuildContext context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid || _isCheckingSubdomain) { if (!isValid || _isCheckingSubdomain) {
return; return;
} }
@ -304,7 +299,6 @@ class _ClientPortalState extends State<ClientPortal>
company.portalMode == kClientPortalModeSubdomain) ...[ company.portalMode == kClientPortalModeSubdomain) ...[
DecoratedFormField( DecoratedFormField(
label: localization.subdomain, label: localization.subdomain,
autovalidate: _autoValidate,
controller: _subdomainController, controller: _subdomainController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
hint: localization.subdomainHelp, hint: localization.subdomainHelp,

View File

@ -53,7 +53,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
TabController _controller; TabController _controller;
bool autoValidate = false;
final _debouncer = Debouncer(sendFirstAction: true); final _debouncer = Debouncer(sendFirstAction: true);
final _nameController = TextEditingController(); final _nameController = TextEditingController();
@ -272,7 +271,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAName ? localization.pleaseEnterAName
: null, : null,
autovalidate: autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
), ),

View File

@ -48,7 +48,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
final _debouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave); final _debouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave);
bool _autoValidate = false;
bool _isSaving = false; bool _isSaving = false;
bool _isSubdomainUnique = false; bool _isSubdomainUnique = false;
bool _isCheckingSubdomain = false; bool _isCheckingSubdomain = false;
@ -127,10 +126,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
void _onSavePressed() { void _onSavePressed() {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid || _isCheckingSubdomain) { if (!isValid || _isCheckingSubdomain) {
return; return;
} }
@ -196,7 +191,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
final companyName = DecoratedFormField( final companyName = DecoratedFormField(
autofocus: true, autofocus: true,
label: localization.companyName, label: localization.companyName,
autovalidate: _autoValidate,
controller: _nameController, controller: _nameController,
validator: (value) => validator: (value) =>
value.isEmpty ? localization.pleaseEnterAValue : null, value.isEmpty ? localization.pleaseEnterAValue : null,
@ -205,7 +199,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
final firstName = DecoratedFormField( final firstName = DecoratedFormField(
label: localization.firstName, label: localization.firstName,
autovalidate: _autoValidate,
controller: _firstNameController, controller: _firstNameController,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
autofillHints: [AutofillHints.givenName], autofillHints: [AutofillHints.givenName],
@ -215,7 +208,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
final lastName = DecoratedFormField( final lastName = DecoratedFormField(
label: localization.lastName, label: localization.lastName,
autovalidate: _autoValidate,
controller: _lastNameController, controller: _lastNameController,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
autofillHints: [AutofillHints.familyName], autofillHints: [AutofillHints.familyName],
@ -278,7 +270,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
final subdomain = DecoratedFormField( final subdomain = DecoratedFormField(
label: localization.subdomain, label: localization.subdomain,
autovalidate: _autoValidate,
controller: _subdomainController, controller: _subdomainController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
validator: (value) { validator: (value) {

View File

@ -55,7 +55,6 @@ class _UserDetailsState extends State<UserDetails>
GlobalKey<FormState>(debugLabel: '_userDetails'); GlobalKey<FormState>(debugLabel: '_userDetails');
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
TabController _controller; TabController _controller;
bool autoValidate = false;
final _firstNameController = TextEditingController(); final _firstNameController = TextEditingController();
final _lastNameController = TextEditingController(); final _lastNameController = TextEditingController();
@ -136,10 +135,6 @@ class _UserDetailsState extends State<UserDetails>
void _onSavePressed(BuildContext context) { void _onSavePressed(BuildContext context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
autoValidate = !isValid ?? false;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -320,7 +315,6 @@ class _UserDetailsState extends State<UserDetails>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAFirstName ? localization.pleaseEnterAFirstName
: null, : null,
autovalidate: autoValidate,
onSavePressed: _onSavePressed, onSavePressed: _onSavePressed,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
), ),
@ -330,7 +324,6 @@ class _UserDetailsState extends State<UserDetails>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterALastName ? localization.pleaseEnterALastName
: null, : null,
autovalidate: autoValidate,
onSavePressed: _onSavePressed, onSavePressed: _onSavePressed,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
), ),
@ -340,7 +333,6 @@ class _UserDetailsState extends State<UserDetails>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterYourEmail ? localization.pleaseEnterYourEmail
: null, : null,
autovalidate: autoValidate,
onSavePressed: _onSavePressed, onSavePressed: _onSavePressed,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
), ),
@ -352,7 +344,6 @@ class _UserDetailsState extends State<UserDetails>
), ),
PasswordFormField( PasswordFormField(
controller: _passwordController, controller: _passwordController,
autoValidate: autoValidate,
onSavePressed: _onSavePressed, onSavePressed: _onSavePressed,
), ),
]), ]),

View File

@ -27,7 +27,6 @@ class _TaskStatusEditState extends State<TaskStatusEdit> {
static final GlobalKey<FormState> _formKey = static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_taskStatusEdit'); GlobalKey<FormState>(debugLabel: '_taskStatusEdit');
final _debouncer = Debouncer(); final _debouncer = Debouncer();
bool _autoValidate = false;
final _nameController = TextEditingController(); final _nameController = TextEditingController();
@ -84,10 +83,6 @@ class _TaskStatusEditState extends State<TaskStatusEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -104,7 +99,6 @@ class _TaskStatusEditState extends State<TaskStatusEdit> {
DecoratedFormField( DecoratedFormField(
autofocus: true, autofocus: true,
controller: _nameController, controller: _nameController,
autovalidate: _autoValidate,
label: localization.name, label: localization.name,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty

View File

@ -28,7 +28,6 @@ class _TaxRateEditState extends State<TaxRateEdit> {
GlobalKey<FormState>(debugLabel: '_taxRateEdit'); GlobalKey<FormState>(debugLabel: '_taxRateEdit');
FocusScopeNode _focusNode; FocusScopeNode _focusNode;
bool autoValidate = false;
final _nameController = TextEditingController(); final _nameController = TextEditingController();
final _rateController = TextEditingController(); final _rateController = TextEditingController();
@ -101,7 +100,6 @@ class _TaxRateEditState extends State<TaxRateEdit> {
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAName ? localization.pleaseEnterAName
: null, : null,
autovalidate: autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
), ),

View File

@ -30,7 +30,6 @@ class _TokenEditState extends State<TokenEdit> {
final _nameController = TextEditingController(); final _nameController = TextEditingController();
List<TextEditingController> _controllers = []; List<TextEditingController> _controllers = [];
bool _autoValidate = false;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
@ -81,10 +80,6 @@ class _TokenEditState extends State<TokenEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
_autoValidate = !isValid;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -102,7 +97,6 @@ class _TokenEditState extends State<TokenEdit> {
autofocus: true, autofocus: true,
controller: _nameController, controller: _nameController,
label: localization.name, label: localization.name,
autovalidate: _autoValidate,
validator: (value) => validator: (value) =>
value.isEmpty || value.trim().isEmpty value.isEmpty || value.trim().isEmpty
? localization.pleaseEnterAName ? localization.pleaseEnterAName

View File

@ -40,7 +40,6 @@ class _UserEditState extends State<UserEdit>
final _debouncer = Debouncer(); final _debouncer = Debouncer();
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
TabController _controller; TabController _controller;
bool autoValidate = false;
final _firstNameController = TextEditingController(); final _firstNameController = TextEditingController();
final _lastNameController = TextEditingController(); final _lastNameController = TextEditingController();
@ -171,10 +170,6 @@ class _UserEditState extends State<UserEdit>
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
setState(() {
autoValidate = !isValid ?? false;
});
if (!isValid) { if (!isValid) {
return; return;
} }
@ -197,7 +192,6 @@ class _UserEditState extends State<UserEdit>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterAFirstName ? localization.pleaseEnterAFirstName
: null, : null,
autovalidate: autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
), ),
@ -207,7 +201,6 @@ class _UserEditState extends State<UserEdit>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterALastName ? localization.pleaseEnterALastName
: null, : null,
autovalidate: autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
), ),
@ -217,7 +210,6 @@ class _UserEditState extends State<UserEdit>
validator: (val) => val.isEmpty || val.trim().isEmpty validator: (val) => val.isEmpty || val.trim().isEmpty
? localization.pleaseEnterYourEmail ? localization.pleaseEnterYourEmail
: null, : null,
autovalidate: autoValidate,
onSavePressed: viewModel.onSavePressed, onSavePressed: viewModel.onSavePressed,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
), ),

View File

@ -77,12 +77,6 @@ class _StubEditState extends State<StubEdit> {
onSavePressed: (context) { onSavePressed: (context) {
final bool isValid = _formKey.currentState.validate(); final bool isValid = _formKey.currentState.validate();
/*
setState(() {
_autoValidate = !isValid;
});
*/
if (!isValid) { if (!isValid) {
return; return;
} }