MacosSearchField<T> constructor
const
MacosSearchField<T> ({
- Key? key,
- List<
SearchResultItem> ? results, - dynamic onResultSelected()?,
- int maxResultsToShow = 5,
- double resultHeight = _kResultHeight,
- Widget emptyWidget = const SizedBox.shrink(),
- TextEditingController? controller,
- FocusNode? focusNode,
- BoxDecoration? decoration = kDefaultRoundedBorderDecoration,
- BoxDecoration? focusedDecoration = kDefaultFocusedBorderDecoration,
- EdgeInsets padding = const EdgeInsets.all(4.0),
- String? placeholder = "Search",
- TextStyle? placeholderStyle = const TextStyle(fontWeight: FontWeight.w400, color: CupertinoColors.placeholderText),
- TextStyle? style,
- TextAlign textAlign = TextAlign.start,
- bool autocorrect = true,
- bool autofocus = false,
- int? maxLines,
- int? minLines,
- bool expands = false,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- ValueChanged<
String> ? onChanged, - List<
TextInputFormatter> ? inputFormatters, - bool? enabled = true,
- GestureTapCallback? onTap,
Creates a macOS-style search field.
To provide a prefilled text entry, pass in a TextEditingController with an initial value to the controller parameter.
To provide a hint placeholder text that appears when the text entry is empty, pass a String to the placeholder parameter.
Based on a MacosTextField widget.
When focused or tapped, it opens an overlay showing a results list of SearchResultItems to choose from.
If searching yields no results, the emptyWidget is shown instead (set by default to SizedBox.shrink).
Set what happens when selecting a suggestion item via the onResultSelected property.
You can also set a callback action individually for each
SearchResultItem via the onSelected
property.
Implementation
const MacosSearchField({
super.key,
this.results,
this.onResultSelected,
this.maxResultsToShow = 5,
this.resultHeight = _kResultHeight,
this.emptyWidget = const SizedBox.shrink(),
this.controller,
this.focusNode,
this.decoration = kDefaultRoundedBorderDecoration,
this.focusedDecoration = kDefaultFocusedBorderDecoration,
this.padding = const EdgeInsets.all(4.0),
this.placeholder = "Search",
this.placeholderStyle = const TextStyle(
fontWeight: FontWeight.w400,
color: CupertinoColors.placeholderText,
),
this.style,
this.textAlign = TextAlign.start,
this.autocorrect = true,
this.autofocus = false,
this.maxLines,
this.minLines,
this.expands = false,
this.maxLength,
this.maxLengthEnforcement,
this.onChanged,
this.inputFormatters,
this.enabled = true,
this.onTap,
});