diff --git a/lib/screens/music_screen.dart b/lib/screens/music_screen.dart index 53e5d860..e4de2c76 100644 --- a/lib/screens/music_screen.dart +++ b/lib/screens/music_screen.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'package:finamp/services/queue_service.dart'; @@ -203,6 +204,8 @@ class _MusicScreenState extends ConsumerState _buildTabController(); } + Timer? _debounce; + return PopScope( canPop: !isSearching, onPopInvoked: (popped) { @@ -223,6 +226,16 @@ class _MusicScreenState extends ConsumerState autofocus: true, keyboardType: TextInputType.text, textInputAction: TextInputAction.search, + onChanged: (value) { + if (_debounce?.isActive ?? false) _debounce!.cancel(); + _debounce = + Timer(const Duration(milliseconds: 400), () { + setState(() { + searchQuery = value; + }); + }); + }, + onSubmitted: (value) => setState(() { searchQuery = value; }), decoration: InputDecoration(