AnimatedSearchBar constructor

const AnimatedSearchBar(
  1. {Key? key,
  2. String label = '',
  3. Alignment labelAlignment = Alignment.centerLeft,
  4. TextAlign labelTextAlign = TextAlign.start,
  5. dynamic onChanged(
    1. String
    )?,
  6. TextStyle labelStyle = const TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
  7. InputDecoration searchDecoration = const InputDecoration(labelText: 'Search', alignLabelWithHint: true, contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), border: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(8)))),
  8. Duration animationDuration = const Duration(milliseconds: 350),
  9. TextStyle searchStyle = const TextStyle(color: Colors.black),
  10. Color? cursorColor,
  11. Duration duration = const Duration(milliseconds: 300),
  12. double height = 60,
  13. Widget closeIcon = const Icon(Icons.close, key: ValueKey('close')),
  14. Widget searchIcon = const Icon(Icons.search, key: ValueKey('search')),
  15. TextEditingController? controller,
  16. dynamic onFieldSubmitted(
    1. String
    )?,
  17. TextInputAction textInputAction = TextInputAction.search,
  18. VoidCallback? onClose}
)

Creates an AnimatedSearchBar widget.

label is the text to display when the search bar is not active. labelAlignment specifies the alignment of the label text. labelTextAlign specifies the text alignment of the label. onChanged is a callback function that is called, when the text in the search bar changes. labelStyle is the style for the label text. searchDecoration is the decoration for the search input field. animationDuration is the duration for the animation, when switching between label and search input. searchStyle is the style for the search input text. cursorColor is the color of the cursor in the search input field. duration is the debounce duration for input changes. height is the height of the search bar. closeIcon is the icon to display when the search bar is active. searchIcon is the icon to display when the search bar is not active. controller is a TextEditingController to control the text input. onFieldSubmitted is a callback function that is called when the user submits the search field. textInputAction is the action to take when the user presses the keyboard's done button.

Implementation

const AnimatedSearchBar(
    {Key? key,
    this.label = '',
    this.labelAlignment = Alignment.centerLeft,
    this.labelTextAlign = TextAlign.start,
    this.onChanged,
    this.labelStyle = const TextStyle(
      fontSize: 14,
      fontWeight: FontWeight.bold,
    ),
    this.searchDecoration = const InputDecoration(
      labelText: 'Search',
      alignLabelWithHint: true,
      contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
      border: OutlineInputBorder(
        borderRadius: BorderRadius.all(Radius.circular(8)),
      ),
    ),
    this.animationDuration = const Duration(milliseconds: 350),
    this.searchStyle = const TextStyle(color: Colors.black),
    this.cursorColor,
    this.duration = const Duration(milliseconds: 300),
    this.height = 60,
    this.closeIcon = const Icon(Icons.close, key: ValueKey('close')),
    this.searchIcon = const Icon(Icons.search, key: ValueKey('search')),
    this.controller,
    this.onFieldSubmitted,
    this.textInputAction = TextInputAction.search,
    this.onClose})
    : super(key: key);