简体   繁体   English

如何在颤动中禁用文本字段中的焦点

[英]how to disable focus in textfield in flutter

I have a widget, I have a drop down menu depending on the amount of data on the map.我有一个小部件,我有一个下拉菜单,具体取决于地图上的数据量。 But the problem is that each of these drop-down menus has an active focus.但问题是这些下拉菜单中的每一个都有一个活动焦点。 And I want this focus to be inactive for everyone.我希望这个焦点对每个人都无效。 But the problem is that this widget has a mandatory focus setting and I can't pick it up, I just need to turn it off!但问题是这个小部件有一个强制焦点设置,我不能拿起它,我只需要把它关掉! Does anyone know how to disable it in all items on my list ??Thenks)有谁知道如何在我列表中的所有项目中禁用它??Thenks)

Widget _buildAdditionFields(SimpleOrderStates state) {
if (state.isAdditionsProgress) {
  return const Padding(
    padding: EdgeInsets.all(Margins.small),
    child: PlatformProgressIndicator(),
  );
} else {

  var name = state.additionEntity?.name ?? '';
  var options = state.additionEntity?.getAddition(0)?.dropdownItems;

     var list = state.additionEntity?.selectedVariants
      .mapIndexed(
          (index, addition) =>  Container(
            padding: const EdgeInsets.all(Margins.little),
            child: _buildDropdownField(
              text: addition!["aditionVariontName"],
              enabled: true,
              progress: false,
              dropdownOptions: [],
              focusNode: FocusNode(),
              applySelected: true,
              action: SvgPicture.asset(Img.dropdownArrow),
              labelText: addition!["additionName"],
              dropdownItemSelected: (item) {
                BlocProvider.of<SimpleOrderBloc>(context).add(
                    SimpleOrderDropdownMenuAdditionItemSelectedEvent(item));
              },
              textChanged: (text) {}
          )),


     ).toList()

  return Column(
    children: list ?? [],
  );
 }

} }

Just after the list is created add在创建列表后添加

FocusScope.of(context).unfocus();

Or或者

FocusScope.of(context).requestFocus(FocusNode());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM