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

时间:2020-01-10 09:33:51

标签: 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(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();
  },
),

0 个答案:

没有答案