gpt4 book ai didi

flutter - 无效的InputConnection

转载 作者:行者123 更新时间:2023-12-03 04:48:52 26 4
gpt4 key购买 nike

我在form中实现textformfield。当我单击文本字段,键盘显示并立即关闭并出现错误时,我在android仿真器中运行。在iOS模拟器中,Android只能完美运行。 error screen record

当我尝试删除表单并将textformfield转换为formfield时,它可以完美运行。我认为关于表单存在android错误。我能做什么?

错误:

W/IInputConnectionWrapper(10839): getTextBeforeCursor on inactive InputConnection W/IInputConnectionWrapper(10839): getSelectedText on inactive InputConnection W/IInputConnectionWrapper(10839): getTextAfterCursor on inactive InputConnection W/IInputConnectionWrapper(10839): beginBatchEdit on inactive InputConnection W/IInputConnectionWrapper(10839): endBatchEdit on inactive InputConnection



格式:
SingleChildScrollView(
child: Form(
key: formKey,
child: Column(
children: <Widget>[
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: entryField(
title: "Haber Başlığı(Zorunlu)",
textEditingController: headerController,
faIcon: FaIcon(
FontAwesomeIcons.horseHead,
color: Colors.deepOrange,
size: 30,
)),
),
lineDivider(),
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: entryField(
title: "Haber İçeriği(Zorunlu)",
textEditingController: descController,
faIcon: FaIcon(
FontAwesomeIcons.userNinja,
color: Colors.deepOrange,
size: 30,
)),
),
lineDivider(),
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: entryField(
title: "Youtube Linki",
textEditingController: youtubeController,
faIcon: FaIcon(
FontAwesomeIcons.youtube,
color: Colors.deepOrange,
size: 30,
)),
),
lineDivider(),
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: entryField(
title: "Diğer Linkler",
textEditingController: otherController,
faIcon: FaIcon(
FontAwesomeIcons.slack,
color: Colors.deepOrange,
size: 30,
)),
),
],
),
),
),

文本字段:
Widget entryField(
{String title,
TextEditingController textEditingController,
FaIcon faIcon}) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
title,
style: GoogleFonts.righteous(
color: Colors.deepOrange,
fontWeight: FontWeight.bold,
fontSize: 20),
),
SizedBox(
height: 10,
),
TextFormField(
validator: (e) {
String yazilacak;

if (title == "Haber Başlığı(Zorunlu)") {
if (e.isEmpty) yazilacak = "Lütfen Başlığı giriniz";
}
if (title == "Haber İçeriği(Zorunlu)") {
if (e.isEmpty) yazilacak = "Lütfen içeriği giriniz";
}
if (title == "Youtube Linki") {
if (e != "" && !e.contains("youtube")) {
if (!e.contains("youtu.be"))
if(!e.contains("https"))
yazilacak = "Lütfen sadece youtube linki giriniz";
} else {
if(!e.contains("https://")&& e!="") yazilacak="Lütfen https:// ekleyin";
}
}
return yazilacak;
},
maxLines: null,
style: GoogleFonts.roboto(color: Colors.limeAccent),
controller: textEditingController,
cursorColor: Colors.limeAccent,
keyboardType: TextInputType.text,
maxLength: title == "Haber Başlığı(Zorunlu)" ? 35 : 200,
decoration: InputDecoration(
counterStyle: TextStyle(color: Colors.limeAccent),
hoverColor: Colors.limeAccent,
focusColor: Colors.limeAccent,
suffixIcon: faIcon,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.limeAccent),
borderRadius: BorderRadius.circular(10.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.lime),
borderRadius: BorderRadius.circular(10.0),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(color: Colors.lime)),
fillColor: Colors.white12,
errorStyle: GoogleFonts.adventPro(
fontSize: 15,
color: Colors.limeAccent,
fontWeight: FontWeight.bold),
filled: true))
],
),
);
}

最佳答案

此问题与Formkey定义位置有关。我在构建部分中定义。现在,我定义了init状态,还可以。

关于flutter - 无效的InputConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61759758/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com