Skip to content

Commit

Permalink
✨ Filtered query more strict.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Feb 20, 2020
1 parent a12be03 commit c0c3a96
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/pages/home/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class SearchPageState extends State<SearchPage> with AutomaticKeepAliveClientMix
}

void search(BuildContext context, String content, {bool isMore = false}) {
if (_controller.text?.trim()?.isNotEmpty ?? false) {
final String query = filteredSearchQuery(content);
if (query?.isNotEmpty ?? false) {
_focusNode.unfocus();
_loading = true;
if (!isMore) {
Expand Down Expand Up @@ -137,6 +138,21 @@ class SearchPageState extends State<SearchPage> with AutomaticKeepAliveClientMix
}
}

String filteredSearchQuery(String query) {
String result;
if (query?.isNotEmpty ?? false) {
result = query
.replaceAll('+', '')
.replaceAll('-', '')
.replaceAll('*', '')
.replaceAll('/', '')
.replaceAll('=', '')
.replaceAll('\$', '')
.trim();
}
return result;
}

Widget get searchButton => IconButton(
icon: Icon(Icons.search, size: suSetWidth(30.0)),
onPressed: () {
Expand Down

0 comments on commit c0c3a96

Please sign in to comment.