suggestionSettings property

  1. @override
AssistSuggestionSettings? suggestionSettings
final

Settings for the suggestions.

The suggestionSettings is used to customize the appearance of the suggestion items such as colors, fonts, item padding, and overflow to ensure a better user experience.

Example:

List<AssistMessage> _messages = <AssistMessage>[
  AssistMessage.response(
    suggestionSettings: AssistSuggestionSettings(
      backgroundColor: Colors.grey[300],
      itemBackgroundColor: WidgetStateProperty.resolveWith<Color>(
        (states) {
          if (states.contains(WidgetState.hovered)) {
            return Colors.grey[400]!;
          }
          return Colors.grey;
        },
      ),
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(4.0)),
      ),
      itemShape: WidgetStateProperty.resolveWith<ShapeBorder>(
          (Set<WidgetState> states) {
        if (states.contains(WidgetState.hovered)) {
          return RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(20),
          );
        }
        return RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(5),
        );
      }),
      padding: const EdgeInsets.only(top: 10, bottom: 10),
      itemPadding:
          const EdgeInsets.symmetric(horizontal: 12, vertical: 8.0),
      orientation: Orientation.portrait,
      runSpacing: 10.0,
      spacing: 10.0,
    ),
  ),
];

Implementation

@override
final AssistSuggestionSettings? suggestionSettings;