Skip to content

Commit

Permalink
Fix #90: update clear icon rendering callback (#98)
Browse files Browse the repository at this point in the history
* Fix #90: update clear icon rendering callback

* Update package version and documentation
  • Loading branch information
koukibadr authored Mar 20, 2024
1 parent 3f92166 commit 018f474
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 50 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _ExampleAppState extends State<ExampleApp> {
Expanded(
child: Padding(
padding: const EdgeInsets.all(15),
child: expansionSearchableList(),
child: renderSimpleSearchableList(),
),
),
Align(
Expand Down Expand Up @@ -113,6 +113,7 @@ class _ExampleAppState extends State<ExampleApp> {

Widget renderSimpleSearchableList() {
return SearchableList<Actor>(
displayClearIcon: false,
seperatorBuilder: (context, index) {
return const Divider();
},
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.11.0"
version: "2.11.1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
92 changes: 46 additions & 46 deletions lib/widgets/search_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
);
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 018f474

Please sign in to comment.