trailingBuilder property

WidgetBuilder? trailingBuilder
final

Custom widget builder for the trailing section of the expanded search bar.

When provided, completely replaces the microphone icon and onMicTap behaviour. Use this to show a "Clear" button, voice-action indicator, or any other widget in the trailing position — matching Flutter's own SearchBar.trailing API.

The builder receives a BuildContext that is a descendant of the expanded glass pill. If null, the standard mic icon / empty logic applies.

Example — clear button

trailingBuilder: (ctx) => GestureDetector(
  onTap: () => searchController.clear(),
  child: Icon(CupertinoIcons.clear_circled_solid,
      color: Colors.white54, size: 18),
),

Implementation

final WidgetBuilder? trailingBuilder;