renderSuggestionTile method

  1. @override
Widget renderSuggestionTile(
  1. BuildContext context,
  2. KeyedOption<K, T> suggestion, {
  3. required bool isSelected,
  4. required SelectOption<K, T> selectOption,
  5. VoidCallback? onTap,
})
override

Renders the suggested tile in the list of options. If you override this method, you should make sure to invoke renderSuggestionTileTrailing

Implementation

@override
Widget renderSuggestionTile(
    BuildContext context, KeyedOption<K, T> suggestion,
    {required bool isSelected,

    /// A callback that allows you to change the selected option
    required SelectOption<K, T> selectOption,

    /// A provided onTap handler for the tile.
    VoidCallback? onTap}) {
  final isAdhocCreator = suggestion is KeyedAdhocOption<K, T> &&
      suggestion.hasAdhocCreator &&
      suggestion.label.isNotNullOrBlank;
  Widget? subtitle() {
    if (isAdhocCreator) {
      return Text("Tap to add this record");
    } else {
      return suggestion.subtitle.toColumn();
    }
  }

  return InputWidgets.buildTypeaheadOption(
    onTap: onTap,
    leading: imageWidgetOf(context, suggestion.icon, size: 30, circle: false),
    title: Text(suggestion.label),
    subtitle: subtitle(),
    trailing: isAdhocCreator
        ? context.icons.add.widget
        : renderSuggestionTileTrailing(
            context,
            suggestion,
            isSelected,
            selectOption,
          ),
  );
}