0

I'm trying to use the AutovalidateMode with the TypeAheadFormField (pub.dev > flutter_typeahead).

I tried to change line 34 on typeahead_form_field.dart to AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction, it did not work.

Then I tried to change line 81 to autovalidateMode: AutovalidateMode.onUserInteractio, it did not work.

Please help.

TypeAheadFormField<Brand>(
    textFieldConfiguration: TextFieldConfiguration(
    controller: TextEditingController(
        text: _selectedBrand?.brandName ?? ''),
        //controller: brandNameController,
        decoration: const InputDecoration(
            isDense: true,
            contentPadding: EdgeInsets.fromLTRB(0, 35, 25, 0),
            label: Text('Select one form the list'),
            prefixIcon: Padding(
                padding: EdgeInsets.only(left: 22, right: 15),
                child: Icon(PhosphorIcons.magnifying_glass_bold)),
            filled: true,
            border: OutlineInputBorder())),
    suggestionsCallback: (pattern) async {
        return brands.where((b) => b.brandName.toLowerCase()
                              .contains(pattern.toLowerCase()))
                          .toList();
                    },
    itemBuilder: (context, Brand b) {
                      return ListTile(
                        title: Text(b.brandName),
                      );
                    },
    onSuggestionSelected: (Brand b) {
                      setState(() {
                        _selectedBrand = b;
                        idBrandController = b.id;
                        brandNameController.text = b.brandName;
                      });
                    },
    validator: (value) {
                      //if (b == null) {
                      //if (value!.isEmpty) {
                      //if (_selectedBrand == null) {
                      if (value == null || value.isEmpty) {
                        return 'Select Store';
                      }
                      return null;
                    },
                  ),
Rod Rodrigues
  • 53
  • 1
  • 9

0 Answers0