Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
"statusBar.background": "#0f0f0f",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#282828",
"statusBarItem.remoteBackground": "#0f0f0f",
"statusBarItem.remoteBackground": "#8f3030",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#0f0f0f",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#0f0f0f99",
"titleBar.inactiveForeground": "#e7e7e799",
"commandCenter.border": "#e7e7e799"
"commandCenter.border": "#e7e7e799",
"activityBarTop.activeBackground": "#282828",
"activityBarTop.background": "#282828",
"activityBarTop.foreground": "#e7e7e7",
"activityBarTop.inactiveForeground": "#e7e7e799",
"commandCenter.foreground": "#e7e7e7",
"statusBar.debuggingBackground": "#0f0f0f",
"statusBar.debuggingForeground": "#e7e7e7"
},
"peacock.color": "0F0F0F",
"editor.codeActionsOnSave": {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Repository: <https://github.com/koukibadr/Searchable-Listview>

This project is licensed under the terms in the `LICENSE` file.

## Authors
## Contributors

<a href="https://github.com/koukibadr/Searchable-Listview/graphs/contributors">
<img src="https://contrib.rocks/image?repo=koukibadr/Searchable-Listview" />
Expand Down
4 changes: 4 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false
32 changes: 28 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,34 @@ class ExampleWidget extends StatelessWidget {
),
body: const TabBarView(
children: [
BasicSearchableListview(),
AsyncSearchableListview(),
SliverSearchableListview(),
ExpansionSearchableListview(),
Padding(
padding: EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
child: BasicSearchableListview(),
),
Padding(
padding: EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
child: AsyncSearchableListview(),
),
Padding(
padding: EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
child: SliverSearchableListview(),
),
Padding(
padding: EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
child: ExpansionSearchableListview(),
),
],
),
),
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.19.4"
version: "2.19.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down
10 changes: 8 additions & 2 deletions lib/searchable_listview.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: must_be_immutable

import 'dart:async';
import 'dart:developer';

import 'package:async/async.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -88,7 +89,7 @@ class SearchableList<T> extends StatefulWidget {
required this.asyncListCallback,
required this.asyncListFilter,
required this.itemBuilder,
this.asyncDebounceTime = 0,
this.asyncDebounceTime = 3000,
Comment thread
koukibadr marked this conversation as resolved.
this.loadingWidget,
this.errorWidget,
this.searchTextController,
Expand Down Expand Up @@ -288,7 +289,7 @@ class SearchableList<T> extends StatefulWidget {

/// Debouncing time when typing in search field in milliseconds
/// Wait [asyncDebounceTime] milliseconds without any new entry before invoking [asyncListFilter]
int asyncDebounceTime = 0;
int asyncDebounceTime = 3000;

/// Loading widget displayed when [asyncListCallback] is loading
/// if nothing is provided in [loadingWidget] searchable list will display a [CircularProgressIndicator]
Expand Down Expand Up @@ -551,6 +552,10 @@ class _SearchableListState<T> extends State<SearchableList<T>> {

@override
void dispose() {
log('disposing searchable listview');
if (widget.focusNode?.hasFocus == true) {
FocusScope.of(context).requestFocus(FocusNode());
}
if (widget.scrollController == null) {
scrollController.dispose();
}
Expand Down Expand Up @@ -802,6 +807,7 @@ class _SearchableListState<T> extends State<SearchableList<T>> {
_debouncer!.run(() async {
if (mounted) setState(() {});
_activeOperation?.cancel();
log('Filtering list with value: $value');
Comment thread
koukibadr marked this conversation as resolved.
await _asyncFilter(value);
if (mounted) setState(() {});
});
Expand Down
Loading