PRFSearchableList<T> class

Searchable picker list with single- and multi-select modes.

Wraps a search field above a list of filtered entries. Passing selections switches to multi-select mode, which renders selected values as removable chips. Single-select is enabled by passing selection instead.

Works inline on normal pages and modally in bottom sheets (showModal).

Example (single select):

PRFSearchableList<Team>(
  entries: teams
      .map((t) => PRFSearchableListEntry(value: t, label: t.name))
      .toList(),
  onSelected: (team) => setState(() => _team = team),
  selection: _team,
)

Example (modal bottom sheet picker):

final team = await PRFSearchableList.showModal<Team>(
  context,
  title: 'Select team',
  entries: teams
      .map((t) => PRFSearchableListEntry(value: t, label: t.name))
      .toList(),
  selection: _team,
);
Inheritance

Constructors

PRFSearchableList({required List<PRFSearchableListEntry<T>> entries, required ValueChanged<T?> onSelected, Key? key, T? selection, List<T>? selections, String hintText = 'Search', String emptyText = 'No results found', double maxResultHeight = 240, double? resultHeight, bool isExpanded = false, bool autoFocus = false, EdgeInsetsGeometry? padding})
const

Properties

autoFocus bool
Automatically focuses the search field when rendered. Defaults to false.
final
effectiveMaxResultHeight double
Effective max result height considering deprecated resultHeight.
no setter
emptyText String
Message shown when no entry matches the query. Defaults to No results found.
final
entries List<PRFSearchableListEntry<T>>
The items available to pick from.
final
hashCode int
The hash code for this object.
no setterinherited
hintText String
Placeholder of the search field. Defaults to Search.
final
isExpanded bool
When true, the results list expands to fill available vertical space (Expanded). Ideal when used inside a bottom sheet or flex container. Defaults to false.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxResultHeight double
Maximum height of the results dropdown when inline. Defaults to 240.
final
onSelected ValueChanged<T?>
Invoked with the picked value — or null when a single selection is cleared. In multi-select mode called with the toggled value.
final
padding EdgeInsetsGeometry?
Optional padding around the searchable list container.
final
resultHeight double?
Deprecated result height override for backwards compatibility.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selection → T?
Single-select: currently selected value. Mutually exclusive with selections.
final
selections List<T>?
Multi-select: currently selected values. When non-null the widget renders in multi-select mode — showing chips for every selected value and allowing multiple items to be picked. Mutually exclusive with selection.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

showModal<T>(BuildContext context, {required String title, required List<PRFSearchableListEntry<T>> entries, T? selection, List<T>? selections, ValueChanged<T?>? onSelected, String hintText = 'Search', String emptyText = 'No results found', bool showHandle = true, double heightFactor = 0.9, bool autoFocus = true, String doneButtonText = 'Done'}) Future<T?>
Presents a searchable picker modally inside a PRFBottomSheet.