Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振|如何始终保持文本字段的焦点(保持显示光标)_Flutter_Dart_Textfield_Flutter Layout_Flutter Dependencies - Fatal编程技术网

Flutter 颤振|如何始终保持文本字段的焦点(保持显示光标)

Flutter 颤振|如何始终保持文本字段的焦点(保持显示光标),flutter,dart,textfield,flutter-layout,flutter-dependencies,Flutter,Dart,Textfield,Flutter Layout,Flutter Dependencies,在这里,我有一个文本字段,我想始终保持焦点,我不想在单击文本字段时打开键盘。简而言之,文本字段始终需要处于焦点位置 这是我的文本字段代码 TextFormField( style: TextStyle( color: Colors.white, fontSize: orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 0.030 : MediaQuery.of

在这里,我有一个文本字段,我想始终保持焦点,我不想在单击文本字段时打开键盘。简而言之,文本字段始终需要处于焦点位置

这是我的文本字段代码

TextFormField(
  style: TextStyle(
    color: Colors.white,
    fontSize: orientation == Orientation.portrait
      ? MediaQuery.of(context).size.width * 0.030
      : MediaQuery.of(context).size.width * 0.020,
  ),
  validator: (val) => Validators.validateRequired(
    val, " Product Baarcode"
  ),
  controller: _addproduct,
  decoration: InputDecoration(
    errorStyle: TextStyle(color: Colors.yellow),
    enabledBorder: UnderlineInputBorder(
      borderSide: BorderSide(color: Colors.white),
    ),
    fillColor: Colors.white,
    focusedBorder: UnderlineInputBorder(
      borderSide: BorderSide(color: Colors.white),
    ),
    hintStyle: TextStyle(color: Colors.white),
    labelStyle: TextStyle(color: Colors.white),
    filled: false,
    prefixIcon: Icon(
      FontAwesomeIcons.barcode,
      color: Colors.white,
    ),
    labelText: "Enter Product Barcode",
    hintText: "Enter Product Barcode",
  ),
  onFieldSubmitted: (val) {
    _addProduct();
  },
),

除了文本字段还有什么?这可以通过FocusNodes实现,但我们需要知道在同一视图中还有哪些其他小部件。想要聚焦在TextFormField上但不想键盘显示的组合是很棘手的。通常通过将焦点移到空的FocusNode来隐藏键盘。但这也将从TextFormField中删除焦点。你能分享一下你为什么要这样做吗?你好,@Joãosaares谢谢你的回答我需要这个,因为我在这个文本字段中有一个文本字段我有一个扫描仪,当我扫描产品时,它会自动填充文本字段内的条形码。这就是为什么我不需要键盘,因为我的文本字段将自动填充。我想始终关注文本字段,因为扫描产品时有发生。如果我正确理解了您的解释,那么我想知道您为什么要使用文本字段?同一视图上是否有更多文本字段?你有一个屏幕截图可以分享,以帮助可视化你想要实现什么?你能建议什么,而不是一个文本字段,我可以使用??