debouncer Note

This commit is contained in:
Rafeek-Khoudare
2025-07-16 11:21:32 +03:00
parent db157f30c5
commit 739b491bd8
2 changed files with 53 additions and 46 deletions

View File

@ -19,7 +19,6 @@ class SpacesStepDetailsWidget extends StatefulWidget {
}
class _SpacesStepDetailsWidgetState extends State<SpacesStepDetailsWidget> {
Timer? _debounce;
ScrollController scrollController = ScrollController();
int currentPage = 1;
String? currentSearchTerm;
@ -94,7 +93,7 @@ class _SpacesStepDetailsWidgetState extends State<SpacesStepDetailsWidget> {
padding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 20),
decoration: const BoxDecoration(
color: Color(0xFFF8F8F8),
color: ColorsManager.circleRolesBackground,
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
@ -102,19 +101,16 @@ class _SpacesStepDetailsWidgetState extends State<SpacesStepDetailsWidget> {
child: SearchUnbookableSpacesWidget(
title: 'Search',
onChanged: (p0) {
if (_debounce?.isActive ?? false) _debounce!.cancel();
_debounce = Timer(const Duration(milliseconds: 500), () {
currentSearchTerm = p0;
currentPage = 1;
context.read<NonBookableSpacesBloc>().add(
LoadUnBookableSpacesEvent(
nonBookableSpacesParams: NonBookableSpacesParams(
currentPage: currentPage,
searchedWords: currentSearchTerm,
),
currentSearchTerm = p0;
currentPage = 1;
context.read<NonBookableSpacesBloc>().add(
LoadUnBookableSpacesEvent(
nonBookableSpacesParams: NonBookableSpacesParams(
currentPage: currentPage,
searchedWords: currentSearchTerm,
),
);
});
),
);
},
),
),