diff --git a/lib/src/components/phone_input/countries_dialog.dart b/lib/src/components/phone_input/countries_dialog.dart index 2f7876db..6539f878 100644 --- a/lib/src/components/phone_input/countries_dialog.dart +++ b/lib/src/components/phone_input/countries_dialog.dart @@ -117,7 +117,6 @@ class _CountriesList extends StatefulWidget { class _CountriesListState extends State<_CountriesList> { late final bool _enableSearch = widget.items.length > 20; - final _controller = TextEditingController(); List _items = []; @override @@ -126,7 +125,8 @@ class _CountriesListState extends State<_CountriesList> { _items = List.from(widget.items); } - void _search(String value) { + void _search(String? text) { + final value = text ?? ''; setState(() { _items = widget.items.where((item) { return item.value.name.toLowerCase().contains(value.toLowerCase()) || @@ -135,19 +135,6 @@ class _CountriesListState extends State<_CountriesList> { }); } - void _clearSearch() { - _controller.clear(); - setState(() { - _items = List.from(widget.items); - }); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - @override Widget build(BuildContext context) { final zeta = widget.zeta ?? Zeta.of(context); @@ -163,22 +150,11 @@ class _CountriesListState extends State<_CountriesList> { if (_enableSearch) Padding( padding: const EdgeInsets.only(bottom: ZetaSpacing.b), - child: TextField( - controller: _controller, + child: ZetaSearchBar( onChanged: _search, - decoration: InputDecoration( - hintText: widget.searchHint ?? 'Search by name or dial code', - prefixIcon: const Icon(ZetaIcons.search_round), - suffixIcon: _controller.text.isEmpty - ? null - : IconButton( - onPressed: _clearSearch, - icon: Icon( - ZetaIcons.cancel_round, - color: zeta.colors.cool.shade70, - ), - ), - ), + hint: widget.searchHint ?? 'Country or dial code', + shape: ZetaWidgetBorder.full, + showSpeechToText: false, ), ), if (_enableSearch)