CustomSearchField<T> class
A widget that displays a searchfield and a list of suggestions
when the searchfield is brought into focus
see example/lib/country_search.dart
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CustomSearchField
Constructors
-
CustomSearchField({Key? key, required List<
SearchFieldListItem< suggestions, bool autoCorrect = true, TextEditingController? controller, Widget emptyWidget = const SizedBox.shrink(), FocusNode? focusNode, String? hint, SearchFieldListItem<T> >T> ? initialValue, List<TextInputFormatter> ? inputFormatters, TextInputType? inputType, double itemHeight = 35.0, Color? marginColor, int maxSuggestionsInViewPort = 5, bool? enabled, bool readOnly = false, dynamic onSubmit(String)?, Offset? offset, dynamic onSuggestionTap(SearchFieldListItem<T> )?, InputDecoration? searchInputDecoration, TextStyle? searchStyle, bool scrollbarAlwaysVisible = true, TextStyle? suggestionStyle, BoxDecoration? suggestionsDecoration, SuggestionDirection suggestionDirection = SuggestionDirection.down, Suggestion suggestionState = Suggestion.expand, BoxDecoration? suggestionItemDecoration, SuggestionAction? suggestionAction, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction? textInputAction, String? validator(String?)?, bool comparator(String inputText, String suggestionKey)?, dynamic onClear()?})
Properties
- autoCorrect → bool
-
Defines whether to enable autoCorrect defaults to
truefinal - comparator → bool Function(String inputText, String suggestionKey)?
-
Function that implements the comparison criteria to filter out suggestions.
The 2 parameters are the input text and the
suggestionKeypassed to eachSearchFieldListItemwhich should return true or false to filter out the suggestion. by default the comparator shows the suggestions that contain the input text in thesuggestionKeyfinal - controller → TextEditingController?
-
Specifies the
TextEditingControllerfor CustomSearchField.final - emptyWidget → Widget
-
Widget to show when the search returns
empty results.
defaults to SizedBox.shrink
final
- enabled → bool?
-
Defines whether to enable the searchfield defaults to
truefinal - focusNode → FocusNode?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String?
-
Hint for the CustomSearchField.
final
-
initialValue
→ SearchFieldListItem<
T> ? -
The initial value to be selected for CustomSearchField. The value
must be present in suggestions.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
input formatter for the searchfield
final
- inputType → TextInputType?
-
Keyboard Type for SearchField
final
- itemHeight → double
-
Specifies height for each suggestion item in the list.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- marginColor → Color?
-
Specifies the color of margin between items in suggestions list.
final
- maxSuggestionsInViewPort → int
-
Specifies the number of suggestions that can be shown in viewport.
final
- offset → Offset?
-
suggestion List offset from the searchfield
The top left corner of the searchfield is the origin (0,0)
final
- onClear → dynamic Function()?
-
final
- onSubmit → dynamic Function(String)?
-
Callback when the Searchfield is submitted
it returns the text from the searchfield
final
-
onSuggestionTap
→ dynamic Function(SearchFieldListItem<
T> )? -
Callback when the suggestion is selected.
final
- readOnly → bool
-
Defines whether to show the searchfield as readOnly
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollbarAlwaysVisible → bool
-
Defines whether to show the scrollbar always or only when scrolling.
defaults to
truefinal - searchInputDecoration → InputDecoration?
-
Specifies InputDecoration for search input TextField.
final
- searchStyle → TextStyle?
-
Specifies TextStyle for search input.
final
- suggestionAction → SuggestionAction?
-
Specifies the SuggestionAction called on suggestion tap.
final
- suggestionDirection → SuggestionDirection
-
suggestion direction defaults to SuggestionDirection.up
final
- suggestionItemDecoration → BoxDecoration?
-
Specifies BoxDecoration for items in suggestion list. The property can be used to add BoxShadow,
and much more. For more information, checkout BoxDecoration.
final
-
suggestions
→ List<
SearchFieldListItem< T> > -
List of suggestions for the searchfield.
each suggestion should have a unique searchKey
final
- suggestionsDecoration → BoxDecoration?
-
Specifies BoxDecoration for suggestion list. The property can be used to add BoxShadow, BoxBorder
and much more. For more information, checkout BoxDecoration.
final
- suggestionState → Suggestion
-
defaults to SuggestionState.expand
final
- suggestionStyle → TextStyle?
-
Specifies TextStyle for suggestions when no child is provided.
final
- textCapitalization → TextCapitalization
-
text capitalization defaults to TextCapitalization.none
final
- textInputAction → TextInputAction?
-
Define a TextInputAction that is called when the field is submitted
final
- validator → String? Function(String?)?
-
validatorfor the CustomSearchField to make use of this validator, The SearchField widget needs to be wrapped in a Form and pass it a Global key and write your validation logic in the validator you can define a global keyfinal
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _CustomSearchFieldState< T> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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