Andrii Havrylyak
Andrii Havrylyak

Reputation: 675

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)

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 ?? [],
  );
 }

}

Upvotes: 0

Views: 1605

Answers (1)

Kaushik Chandru
Kaushik Chandru

Reputation: 17762

Just after the list is created add

FocusScope.of(context).unfocus();

Or

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

Upvotes: 2

Related Questions