dartora

Searchable

Searchable is the abstract base class for any item that can participate in a search. It defines common properties such as an identifier, display name and description, and a set of tags, and it supports a parent/child hierarchy. Concrete implementations provide storage for child items and may customise event handling.

Properties

Construction and factory

Searchable({ required String id, required SearchableType type, String description = '', String title = '', required Tags tags })

factory Searchable.build({
  required String id,
  required String name,
  required SearchableType type,
  String description = '',
  String title = '',
  required Tags tags,
  List<Searchable>? children,
  EventAction? onHolderEvent,
})

The factory returns a DefaultSearchable, a concrete implementation that stores the name in a final field and instantiates a ChildHolder for the provided children. The onHolderEvent callback is passed down to the holder to handle add/remove events.

Hierarchy

A Searchable can contain children if its type is SearchableType.parent. Children are managed via a ChildHolder, which tracks keys, types and events. When a child is added to a parent, its _parent field is set to the parent. Removing a child clears its parent reference.

Notes