diff --git a/example/lib/main.dart b/example/lib/main.dart index 1bd46f9..07c305b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -49,7 +49,7 @@ class _MyHomePageState extends State { tileLabel: (user) => user!.name, emptySearchChild: const Center(child: Text('No user found')), // enableOnlySingleSelection: true, - searchFieldHint: 'Search Here..', + searchFieldHint: '', /*suggestionBuilder: (context, user, isSelected) { return ListTile( title: Text(user.name!), @@ -76,6 +76,7 @@ class _MyHomePageState extends State { choiceChipTheme: ChoiceChipThemeData.light(context), ), headlineText: 'Select Users', + searchFieldHint: '', height: 500, listData: userList, selectedListData: selectedUserList, diff --git a/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index d6f318d..e157ccb 100644 --- a/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/sonusharma/Downloads/flutter -FLUTTER_APPLICATION_PATH=/Users/sonusharma/Desktop/workspace/opensource/flutter_plugin_filter_list/example +FLUTTER_ROOT=/home/arakakil/snap/flutter/common/flutter +FLUTTER_APPLICATION_PATH=/home/arakakil/git/flutter_plugin_filter_list/example COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_BUILD_DIR=build FLUTTER_BUILD_NAME=1.0.0 diff --git a/example/macos/Flutter/ephemeral/flutter_export_environment.sh b/example/macos/Flutter/ephemeral/flutter_export_environment.sh index 306ccd4..069a9e5 100755 --- a/example/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/example/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/sonusharma/Downloads/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/sonusharma/Desktop/workspace/opensource/flutter_plugin_filter_list/example" +export "FLUTTER_ROOT=/home/arakakil/snap/flutter/common/flutter" +export "FLUTTER_APPLICATION_PATH=/home/arakakil/git/flutter_plugin_filter_list/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" diff --git a/example/pubspec.lock b/example/pubspec.lock index 07342c0..e959336 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: @@ -74,46 +74,62 @@ packages: description: flutter source: sdk version: "0.0.0" - js: + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: dependency: transitive description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "3.0.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.15.0" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -123,26 +139,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -163,10 +179,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.7.2" vector_math: dependency: transitive description: @@ -175,6 +191,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + url: "https://pub.dev" + source: hosted + version: "14.2.5" sdks: - dart: ">=2.18.0 <4.0.0" - flutter: ">=1.12.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 197f627..825c209 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,7 +11,7 @@ description: A new Flutter project. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 1.0.2+2 publish_to: none environment: sdk: '>=2.12.0 <3.0.0' diff --git a/lib/src/filter_list_dialog.dart b/lib/src/filter_list_dialog.dart index ca26854..211f79b 100644 --- a/lib/src/filter_list_dialog.dart +++ b/lib/src/filter_list_dialog.dart @@ -76,7 +76,6 @@ part 'filter_list_widget.dart'; class FilterListDialog { static Future display( BuildContext context, { - /// Filter theme FilterListThemeData? themeData, @@ -117,6 +116,9 @@ class FilterListDialog { /// Headline text to be display as header of dialog. String? headlineText, + /// Text to be displayed as a hint in the search field. + String? searchFieldHint, + /// Used to hide selected text count. bool hideSelectedTextCount = false, @@ -208,6 +210,7 @@ class FilterListDialog { choiceChipLabel: choiceChipLabel, hideHeader: hideHeader, headlineText: headlineText, + searchFieldHint: searchFieldHint, onItemSearch: onItemSearch, backgroundColor: backgroundColor, selectedListData: selectedListData, diff --git a/lib/src/filter_list_widget.dart b/lib/src/filter_list_widget.dart index 8a9a2b0..6e60792 100644 --- a/lib/src/filter_list_widget.dart +++ b/lib/src/filter_list_widget.dart @@ -66,6 +66,7 @@ class FilterListWidget extends StatelessWidget { this.headerCloseIcon, this.onCloseWidgetPress, this.headlineText, + this.searchFieldHint, this.hideSelectedTextCount = false, this.hideSearchField = false, this.hideCloseIcon = true, @@ -94,6 +95,7 @@ class FilterListWidget extends StatelessWidget { final Color? backgroundColor; final String? headlineText; + final String? searchFieldHint; final bool hideSelectedTextCount; final bool hideSearchField; @@ -177,6 +179,7 @@ class FilterListWidget extends StatelessWidget { Header( headlineText: headlineText, hideSearchField: hideSearchField, + searchFieldHint: searchFieldHint, hideCloseIcon: hideCloseIcon, headerCloseIcon: headerCloseIcon, onSearch: (String value) { diff --git a/lib/src/state/filter_state.dart b/lib/src/state/filter_state.dart index d2b01f3..7ce33fc 100644 --- a/lib/src/state/filter_state.dart +++ b/lib/src/state/filter_state.dart @@ -5,12 +5,14 @@ class FilterState extends ListenableState { FilterState({List? allItems, List? selectedItems}) { this.selectedItems = selectedItems; items = allItems; + _allItems = allItems; } static FilterState of(BuildContext context) => StateProvider.of>(context); /// List of all items + List? _allItems; List? _items; List? get items => _items; set items(List? value) { @@ -57,7 +59,7 @@ class FilterState extends ListenableState { // perform filter operation void filter(bool Function(K) filter) { - _items = _items!.where(filter).toList(); + _items = _allItems!.where(filter).toList(); notifyListeners(); } diff --git a/lib/src/widget/header.dart b/lib/src/widget/header.dart index 0f0ef4a..e74517d 100644 --- a/lib/src/widget/header.dart +++ b/lib/src/widget/header.dart @@ -11,6 +11,7 @@ class Header extends StatelessWidget { this.headerCloseIcon, this.hideSearchField = false, this.onCloseWidgetPress, + this.searchFieldHint, }) : super(key: key); final String? headlineText; @@ -20,6 +21,8 @@ class Header extends StatelessWidget { final ValueChanged onSearch; final void Function()? onCloseWidgetPress; + final String? searchFieldHint; + @override Widget build(BuildContext context) { final headerTheme = FilterListTheme.of(context).headerTheme; @@ -80,7 +83,8 @@ class Header extends StatelessWidget { if (!hideSearchField) ...[ Padding( padding: const EdgeInsets.only(right: 8), - child: SearchFieldWidget(onChanged: onSearch), + child: SearchFieldWidget( + onChanged: onSearch, searchFieldHint: searchFieldHint), ), ] ], diff --git a/lib/src/widget/search_field_widget.dart b/lib/src/widget/search_field_widget.dart index 5b0ed66..63166ef 100644 --- a/lib/src/widget/search_field_widget.dart +++ b/lib/src/widget/search_field_widget.dart @@ -3,9 +3,12 @@ import 'package:flutter/material.dart'; class SearchFieldWidget extends StatelessWidget { final ValueChanged onChanged; + + final String? searchFieldHint; const SearchFieldWidget({ Key? key, required this.onChanged, + this.searchFieldHint, }) : super(key: key); @override @@ -26,7 +29,7 @@ class SearchFieldWidget extends StatelessWidget { decoration: InputDecoration( prefixIcon: Icon(Icons.search, color: headerTheme.searchFieldIconColor), - hintText: headerTheme.searchFieldHintText, + hintText: searchFieldHint ?? headerTheme.searchFieldHintText, hintStyle: headerTheme.searchFieldHintTextStyle, border: headerTheme.searchFieldInputBorder, ), diff --git a/pubspec.lock b/pubspec.lock index d32221b..df9b838 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" fake_async: dependency: transitive description: @@ -59,46 +59,62 @@ packages: description: flutter source: sdk version: "0.0.0" - js: + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: dependency: transitive description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "3.0.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.15.0" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -108,26 +124,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -148,10 +164,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.7.2" vector_math: dependency: transitive description: @@ -160,6 +176,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + url: "https://pub.dev" + source: hosted + version: "14.2.5" sdks: - dart: ">=2.18.0 <4.0.0" - flutter: ">=1.12.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54"