flutter - 选择 Tex Field flutter 时的输入警告
问题描述
我正在玩一个颤振的应用程序,我有一个 TextField。但是,当我单击 TextField 时,键盘显示并且一切运行正常,但我收到了一堆警告/通知。以下是警告:
W/IInputConnectionWrapper(26234): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(26234): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(26234): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper(26234): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(26234): endBatchEdit on inactive InputConnection
飞镖代码:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyWidget extends StatefulWidget{
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget>{
bool _isClicked = false;
int _clickCounter = 0;
String _inputText;
final controller = TextEditingController();
@override
void dispose() {
// Clean up the controller when the widget is disposed.
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context){
return Column(children: [
TextField(
controller: controller,
onSubmitted: (String text) {
setState(() {
_inputText = text;
});
},
decoration: InputDecoration(
hintText: "Whatever you want.",
)
),
Row(children: [
ElevatedButton(
child: Text("Show input"),
onPressed: (){
setState(() {
_inputText = controller.text;
});
},
),
Text("Your input: $_inputText")
],
mainAxisAlignment: MainAxisAlignment.center,
),
InteractiveViewer(child:
Image(
image: _isClicked ? AssetImage("images/download1.jpg") : AssetImage("images/download.jpg"),
)
),
Row(children: [
IconButton(
icon: _isClicked ? Icon(Icons.favorite) : Icon(Icons.favorite_outline),
color: Colors.blue,
// on pressed for icons
onPressed: (){
setState(() {
if(_isClicked){
_isClicked = false;
} else {
_isClicked = true;
}
});
}
),
Text(_isClicked ? "Favourited" : "Unfavourited"),
],
mainAxisAlignment: MainAxisAlignment.center,
),
Text("This button was clickded $_clickCounter times."),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RaisedButton(
child: Text("Click"),
color: Colors.green[400],
// on pressed for click button
onPressed: (){
setState(() {
_clickCounter++;
});
},
),
RaisedButton(
color: Colors.red,
child: Text("Reset"),
// on pressed for reset
onPressed: (){
setState(() {
_clickCounter = 0;
_isClicked = false;
});
}
),
]
)
],
);
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Button Stuff",
home: Scaffold(
appBar: AppBar(
title: Text("App Bar"),
actions: [
Text("Action1")
],
),
body: SingleChildScrollView(
// stateful widget plugin
child: MyWidget(),
),
)
);
}
}
我想知道为什么这些会出现在我的 cmd 中以及如何摆脱它们。任何帮助将非常感激!
解决方案
推荐阅读
- npm - 了解 Tailwind CSS for React 的 npm install 命令
- php - 如何在 WordPress 中使用简码回显 div 元素
- javascript - 如何循环 JSON 数据并将其部分放入另一个数组中?
- c# - 在 .net core wep api 中更改 appsettings 文件中的连接字符串参数
- reactjs - 如何使用 Auth0 SDK 处理访问令牌和 API 调用?
- c# - 编译 Autorest 生成的客户端时出错
- java - 保留 html、css、javascript 或任何东西
不变,其余转换为 ASCII 字符 - javascript - 仅在 DynamoDB 中使用分区键时,键上的条件数无效
- sorting - 如何对 perl 哈希进行排序?
- typescript - 基于类状态的类字段类型