Issue
I try to simple page with textfield, when I click textfield, these errors appears(If they are errors), Flutter doctor no issues, I am working with real device,Samsung Galaxy A50 (SM-A505F),
src="https://i.stack.imgur.com/eIgy5.png" alt="enter image description here" />
These ones appear, when I just clicked to write texfield, then If I write, a error appears for each character
then If I click next, sometimes I don't even need to click next
LoginView, And Custom TextField,
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:shopping/core/constants/padding/padding_constants.dart';
import 'package:shopping/core/constants/textstyle/text_styles.dart';
import 'package:shopping/core/init/translations/locale_keys.g.dart';
import 'package:shopping/product/widget/textfield/custom_textfield.dart';
class LoginView extends StatefulWidget {
const LoginView({Key? key}) : super(key: key);
@override
State<LoginView> createState() => _LoginViewState();
}
class _LoginViewState extends State<LoginView> {
//Controllers
late final TextEditingController _emailController;
// FocusNodes
late final FocusNode _emailFocusNode;
@override
void initState() {
super.initState();
_emailController = TextEditingController();
_emailFocusNode = FocusNode();
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: Column(
children: [
Text(
LocaleKeys.login.tr(),
style: TextStylesConstants.titleTextStyle,
),
Padding(
padding: PaddingConstants.onlyTopSmall,
child: Text(
LocaleKeys.addYourDetailsToLogin.tr(),
style: Theme.of(context).textTheme.subtitle1,
),
),
Padding(
padding: PaddingConstants.onlyTopMedium,
child: CustomTextField(
controller: _emailController,
focusNode: _emailFocusNode,
keyboardType: TextInputType.emailAddress,
hintText: LocaleKeys.yourEmail.tr(),
),
),
],
),
),
);
}
}
class CustomTextField extends StatelessWidget {
const CustomTextField(
{Key? key, required this.controller, this.focusNode, required this.keyboardType, required this.hintText})
: super(key: key);
final TextEditingController controller;
final FocusNode? focusNode;
final TextInputType keyboardType;
final String hintText;
@override
Widget build(BuildContext context) {
return Center(
child: Container(
width: context.dynamicWidth(0.9),
height: context.dynamicHeight(0.069),
decoration: const BoxDecoration(
color: ColorConstants.textFieldColor,
borderRadius: BorderRadius.all(
Radius.circular(90),
),
),
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: TextField(
textInputAction: TextInputAction.next,
cursorColor: ColorConstants.brightOrange,
cursorRadius: const Radius.circular(45),
controller: controller,
focusNode: focusNode,
keyboardType: keyboardType,
decoration: InputDecoration(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(color: ColorConstants.textFieldColor),
),
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: ColorConstants.textFieldColor,
),
),
hintText: hintText,
hintStyle: TextStylesConstants.textFieldTextStyle,
),
),
),
),
),
);
}
}
https://github.com/flutter/flutter/issues/98505#issuecomment-1067976038 this one must fix SamsungSmartSugges.... keepsstopping, but rest of errors still error
Solution
TextField --> TextFormField
wrap all TextFormField with a Form and give a key
https://docs.flutter.dev/cookbook/forms/validation
Form(
key: formKey,
child: Column(
children: [
const Text(
'Please log in to your account in order to interact with and create notes and talk friends',
),
EmailTextFormField(emailController: emailController),
PasswordTextFormField(passwordController: passwordController),
LoginButton(emailController: emailController, passwordController: passwordController),
const ForgotPasswordButton(),
const SignInWithGoogleButton(),
const NotRegisterYetButton()
],
),
),
Answered By - Skyturkish
Answer Checked By - Timothy Miller (JavaFixing Admin)