I'm new in Flutter and have been trying to find a solution for this, but is there a way I can just accept the username ignoring if it's lowercase or uppercase? As long as it matches with their username it's fine to proceed.
Widget emailField() {
return TextFormField(
textInputAction: TextInputAction.next,
keyboardType: TextInputType.emailAddress,
focusNode: emailNode,
validator: validateEmpty,
decoration: InputDecoration(
hintText: 'Username',
prefixIcon: const Icon(Icons.account_circle),
labelStyle: Label,
fillColor: Colors.transparent,
),
//validator: validateEmail,
onSaved: (String? value) {
email = value as String;
},
);
}
submit() async {
if (formKey1.currentState!.validate()) {
formKey1.currentState!.save();
if (_prefs.userSession!.username == email) {
EasyLoading.instance.userInteractions = false;
EasyLoading.show(status: 'Deleting account...');
final response = await authService.masterDelete();
if (_prefs.userSession!.username != email) {
AwesomeDialog(
context: context,
dialogType: DialogType.ERROR,
title: 'ERROR',
desc: 'Incorrect username',
btnCancelText: 'Accept',
btnCancelOnPress: () {},
).show();
}
CodePudding user response:
If it's only about ignoring lowercase/uppercase, then use toLowerCase()
on both strings and compare them:
String mailOne = "[email protected]";
String mailTwo = "[email protected]";
print(mailOne.toLowerCase() == mailOne.toLowerCase()); // -> true