Skip to content

Make Autocomplete show a custom options view while optionsBuilder future is being resolved #147377

@victorsanni

Description

@victorsanni

Use case

Currently in RawAutocomplete, when the field is changed, updateOptionsViewVisibility is only called after the optionsBuilder future has resolved:

  // Called when _textEditingController changes.
  Future<void> _onChangedField() async {
    final TextEditingValue value = _textEditingController.value;
    final Iterable<T> options = await widget.optionsBuilder(value);
    ...

    // Make sure the options are no longer hidden if the content of the field
    // changes (ignore selection changes).
    if (value.text != _lastFieldText) {
      _lastFieldText = value.text;
      _updateOptionsViewVisibility();
    }
  }

This means that users cannot currently display a custom options view while waiting for options from optionsBuilder. This might be useful, for example, if the user wants to display a loading message while waiting for options:

ScreenRecording2024-04-25at9 53 14AM-ezgif com-video-to-gif-converter

Proposal

Allow users display a custom options view while waiting for options from optionsBuilder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions