flutter - W/IInputConnectionWrapper(1768):非活动 InputConnection Flutter 上的 getSelectedText
问题描述
我正在学习颤振,并且遇到了这些错误,我尝试过搜索,但都是徒劳的。
错误:
W/IInputConnectionWrapper( 1768): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 1768): requestCursorAnchorInfo on inactive InputConnection
W/IInputConnectionWrapper( 1768): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 1768): getTextBeforeCursor on inactive InputConnection
问题:
当我单击文本字段时会发生这种情况,但它有一个转折点。当我第一次去这个小部件并选择文本字段来写电子邮件时,没有发生错误。但是当我移动到另一个活动或通过来回返回这个活动时,当我单击任何输入字段时,它会给出这些错误。
请帮忙。
代码:
import 'package:brew_crew/services/auth.dart';
import 'package:flutter/material.dart';
final _formKey = GlobalKey<FormState>();
class SignIn extends StatefulWidget {
@override
_SignInState createState() => _SignInState();
}
class _SignInState extends State<SignIn> {
final AuthService _auth = AuthService();
final emailController = TextEditingController();
final passwordController = TextEditingController();
@override
void dispose()
{
emailController.dispose();
passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.brown[50],
appBar: AppBar(title: Text('Sign In'), backgroundColor: Colors.brown),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal:50.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Brew Crew',
style: TextStyle(
color: Colors.brown,
fontSize: 48.0,
fontWeight: FontWeight.w200,
letterSpacing: 5.0,
),
),
Text(
'The App',
style: TextStyle(
color: Colors.brown,
fontSize: 18.0,
fontWeight: FontWeight.w700,
letterSpacing: 1.0,
),
),
SizedBox(height:30.0),
TextFormField(
controller: emailController,
decoration: InputDecoration(labelText: 'Your email address'),
cursorColor: Colors.brown,
validator: (value) {
if(value.isEmpty)
return 'Email cannot be empty';
else if(!value.contains('@'))
return 'Email must contain @ symbol';
else
return null;
},
),
TextFormField(
controller: passwordController,
decoration: InputDecoration(labelText: 'Your password'),
obscureText: true,
validator: (value) {
if(value.isEmpty)
return 'Password cannot be empty';
else if(value.length < 6)
return 'Password should be at least 6 characters';
else
return null;
},
),
SizedBox(height: 30.0,),
RaisedButton.icon(
onPressed: (){
if(_formKey.currentState.validate())
{
print('Email: ${emailController.text}');
print('Password: ${passwordController.text}');
}
},
color: Colors.brown,
textColor: Colors.white,
icon: Icon(Icons.input),
label: Text('Log In'),
),
SizedBox(height: 20.0,),
GestureDetector(
onTap: () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => Register()));
},
child: Text(
'Not a user? Click here to register',
style: TextStyle(
color: Colors.brown,
),
)
),
],
)
),
),
);
}
}
解决方案
推荐阅读
- python - 无法在 pyspark 中成功提取时间戳到日期和时间
- python - 如何使用python将从excel中提取的数据输入到网站中?
- java - 在 Android Studio 中根据参数舍入浮点数或双精度数
- java - 如何修复 NoSuchElementException 扫描程序?
- java - 如何在heroku中获取我的项目的公共IP?
- git - GitHub 创建子模块而不是简单的文件夹
- javascript - 如何正确使用一个“当前”数组来管理多个数组?
- javascript - Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined (JavaScript)
- python - 如何让每个线程从我的 txt 文件中逐行使用下一个用户代理
- unity3d - 为什么这个计算着色器会跳过每 17 个缓冲区值?