title: Flutter typeahead textField in a reactive_forms custom widget not displaying the selected option text
body: <p>I'm using <a href="https://pub.dev/packages/flutter_typeahead" rel="nofollow noreferrer">Flutter Typeahead</a> to use a google maps places autocomplete. Everything is working fine except that I can't get the textField to show the selected suggestion text. I am setting the <code>TextEditingController.text</code> to some valid text and it just doesn't display anything in the TextField:</p>
  <pre><code>viewModel.typeAheadController.text =
                                suggestion.structuredFormatting.mainText;
  </code></pre>
  <p>Why will the selected suggestion text not display in the TextField, when I have set the text value on the <code>TextEditingController</code> upon selecting the option?</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter_riverpod/flutter_riverpod.dart';
  import 'package:flutter_typeahead/flutter_typeahead.dart';
  import 'package:font_awesome_flutter/font_awesome_flutter.dart';
  import 'package:freezed_annotation/freezed_annotation.dart';
  import 'package:google_maps_webservice/places.dart';
  import 'package:reactive_forms/reactive_forms.dart';
  import 'package:flutter/widgets.dart';
  import 'package:vepo/fonts.gen.dart';
  import 'package:vepo/src/domain/entities/establishment/establishment_domain_entity.dart';
  import 'package:vepo/src/presentation/widgets/purely_display_widgets/text/caption_widget.dart';
  import 'establishments_autocomplete_field_view_model.dart';
  
  class VpEstablishmentsAutocompleteField
      extends ReactiveFormField&lt;EstablishmentDomainEntity&gt; {
    VpEstablishmentsAutocompleteField(
        {@required String formControlName,
        this.context,
        this.label,
        this.hint,
        bool hasFocus = false,
        this.onFocusChange,
        Map&lt;String, String&gt; Function(AbstractControl&lt;dynamic&gt;) validationMessages,
        this.key})
        : super(
              key: key,
              formControlName: formControlName,
              validationMessages: validationMessages,
              showErrors: (control) =&gt; control.invalid,
              builder: (ReactiveFormFieldState&lt;EstablishmentDomainEntity&gt; field) {
                final viewModel = ProviderContainer()
                    .read&lt;EstablishmentsAutocompleteFieldViewModel&gt;(
                        establishmentsAutocompleteViewModelProvider);
                return FocusScope(
                    child: Focus(
                        onFocusChange: (isFocused) {
                          hasFocus = isFocused;
                          if (onFocusChange != null) {
                            onFocusChange(isFocused);
                          }
                          field.setState(() {});
                        },
                        child: TypeAheadFormField&lt;Prediction&gt;(
                          textFieldConfiguration: TextFieldConfiguration(
                            controller: viewModel.typeAheadController,
                            autofocus: true,
                            decoration: InputDecoration(
                                errorMaxLines: 3,
                                suffixIconConstraints: const BoxConstraints(
                                  minWidth: 2,
                                  minHeight: 2,
                                ),
                                suffixIcon: ReactiveStatusListenableBuilder(
                                  formControlName: formControlName,
                                  builder: (context, control, child) {
                                    return control.pending
                                        ? Container(
                                            width: 90,
                                            height: 60,
                                            child: Stack(children: [
                                              Positioned(
                                                top: 10,
                                                right: 15,
                                                child: CircularProgressIndicator(
                                                    backgroundColor:
                                                        Theme.of(context)
                                                            .primaryColorDark),
                                              )
                                            ]))
                                        : Container(width: 0);
                                  },
                                ),
                                alignLabelWithHint: true,
                                labelStyle: TextStyle(
                                    height: 0,
                                    fontSize: hasFocus ? 24 : 18.0,
                                    color: Theme.of(context).primaryColor),
                                hintText: hint,
                                labelText: label,
                                counterText: ''),
                          ),
                          suggestionsCallback: (pattern) async {
                            return await viewModel.fetchSuggestions(
                                pattern, context);
                          },
                          suggestionsBoxDecoration: SuggestionsBoxDecoration(
                            elevation: 20,
                            color: Theme.of(context).scaffoldBackgroundColor,
                            borderRadius: const BorderRadius.all(
                              Radius.circular(10.0),
                            ),
                          ),
                          itemBuilder: (context, suggestion) {
                            return ListTile(
                              leading: FaIcon(FontAwesomeIcons.storeAlt,
                                  size: 25,
                                  color: Theme.of(context).primaryColor),
                              title: RichText(
                                text: TextSpan(
                                  text: viewModel.getBoldText(
                                      suggestion.structuredFormatting.mainText,
                                      suggestion.structuredFormatting
                                          .mainTextMatchedSubstrings.first),
                                  style: TextStyle(
                                      fontSize: 20,
                                      fontFamily: FontFamily.hind,
                                      fontWeight: FontWeight.bold,
                                      color: Theme.of(context).primaryColorDark),
                                  children: &lt;TextSpan&gt;[
                                    TextSpan(
                                        text: suggestion
                                            .structuredFormatting.mainText
                                            .substring(suggestion
                                                .structuredFormatting
                                                .mainTextMatchedSubstrings
                                                .first
                                                .length as int),
                                        style: const TextStyle(
                                            fontWeight: FontWeight.w200,
                                            color: Colors.black54))
                                  ],
                                ),
                              ),
                              subtitle: VpCaption(
                                text:
                                    suggestion.structuredFormatting.secondaryText,
                                color: Colors.black54,
                                fontSize: 17,
                                overflow: TextOverflow.visible,
                              ),
                            );
                          },
                          onSuggestionSelected: (suggestion) {
                            viewModel.typeAheadController.text =
                                suggestion.structuredFormatting.mainText;
                            viewModel.typeAheadController.value =
                                TextEditingValue(
                                    text:
                                        suggestion.structuredFormatting.mainText);
                            final x = EstablishmentDomainEntity(
                                placeId: suggestion.placeId);
  
                            field.didChange(x);
                            field.control.markAsTouched();
                            field.control.markAsDirty();
                          },
                        )));
              });
    final Key key;
    final BuildContext context;
    final String label;
    final String hint;
    bool hasFocus;
    final void Function(bool) onFocusChange;
    @override
    ReactiveFormFieldState&lt;EstablishmentDomainEntity&gt; createState() =&gt;
        ReactiveFormFieldState&lt;EstablishmentDomainEntity&gt;();
  }
  </code></pre>