diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f91b36..55e1934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.11.1 - 16/03/2024 + +* **Fix Bug** + - Update rendering clear icon when `displayClearIcon == false` and `inputDecoration != null` [Issue#90](https://github.com/koukibadr/Searchable-Listview/issues/90) + ## 2.11.0 - 16/03/2024 * **Enhancements** diff --git a/README.md b/README.md index b690ae7..3e6a6bf 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ In order to add searchable listview package to your project add this line to you ```yaml dependencies: - searchable_listview: ^2.11.0 + searchable_listview: ^2.11.1 ``` ## Attributes diff --git a/example/lib/main.dart b/example/lib/main.dart index 3303c98..18f7834 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -65,7 +65,7 @@ class _ExampleAppState extends State { Expanded( child: Padding( padding: const EdgeInsets.all(15), - child: expansionSearchableList(), + child: renderSimpleSearchableList(), ), ), Align( @@ -113,6 +113,7 @@ class _ExampleAppState extends State { Widget renderSimpleSearchableList() { return SearchableList( + displayClearIcon: false, seperatorBuilder: (context, index) { return const Divider(); }, diff --git a/example/pubspec.lock b/example/pubspec.lock index 06c8432..1b38d2a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -145,7 +145,7 @@ packages: path: ".." relative: true source: path - version: "2.11.0" + version: "2.11.1" sky_engine: dependency: transitive description: flutter diff --git a/lib/widgets/search_text_field.dart b/lib/widgets/search_text_field.dart index e8ec820..00043ac 100644 --- a/lib/widgets/search_text_field.dart +++ b/lib/widgets/search_text_field.dart @@ -104,35 +104,35 @@ class SearchTextField extends StatelessWidget { focusNode: focusNode, enabled: searchFieldEnabled, decoration: inputDecoration?.copyWith( - suffixIcon: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - (inputDecoration?.suffixIcon ?? - _renderSuffixIcon())!, - const SizedBox( - width: 5, + suffixIcon: inputDecoration?.suffixIcon ?? + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 5, ), - if (displaySortWidget) - InkWell( - onTap: () { - FocusScope.of(context).requestFocus( - FocusNode(), - ); - onSortTap?.call(); - }, - child: sortWidget ?? - const Icon( - Icons.sort, - ), - ), - ], - ), - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + if (displayClearIcon) renderClearIcon(), + const SizedBox( + width: 5, + ), + if (displaySortWidget) + InkWell( + onTap: () { + FocusScope.of(context).requestFocus( + FocusNode(), + ); + onSortTap?.call(); + }, + child: sortWidget ?? + const Icon( + Icons.sort, + ), + ), + ], + ), + ), ), style: textStyle, controller: searchTextController, @@ -156,23 +156,23 @@ class SearchTextField extends StatelessWidget { ); } - Widget? _renderSuffixIcon() { - return !displayClearIcon - ? null - : searchTextController!.text.isNotEmpty - ? InkWell( - onTap: () { - searchTextController?.clear(); - filterList(searchTextController?.text ?? ''); - }, - child: Icon( - Icons.clear, - color: defaultSuffixIconColor, - ), - ) - : Icon( - Icons.search, - color: defaultSuffixIconColor, - ); + Widget renderClearIcon() { + if (searchTextController!.text.isNotEmpty) { + return InkWell( + onTap: () { + searchTextController?.clear(); + filterList(searchTextController?.text ?? ''); + }, + child: Icon( + Icons.clear, + color: defaultSuffixIconColor, + ), + ); + } else { + return Icon( + Icons.search, + color: defaultSuffixIconColor, + ); + } } } diff --git a/pubspec.yaml b/pubspec.yaml index f35a4b1..b369c3b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: searchable_listview description: A new easy way to filter listview with simple implementation with possibilty to customize search field and empty widget -version: 2.11.0 +version: 2.11.1 homepage: 'https://github.com/koukibadr/Searchable-Listview' environment: sdk: '>=2.12.0 <4.0.0'