SearchFix Assisted-By:Gemini

This commit is contained in:
Akshat-104 2026-05-19 20:58:03 +05:30
parent 2cc8d2620d
commit 5f94461071

View File

@ -59,6 +59,7 @@ class SearchPage extends HookConsumerWidget {
void onSubmitted(String value) { void onSubmitted(String value) {
ref.read(searchTermStateProvider.notifier).state = value; ref.read(searchTermStateProvider.notifier).state = value;
focusNode.unfocus();
if (value.trim().isEmpty) { if (value.trim().isEmpty) {
return; return;
} }
@ -127,19 +128,7 @@ class SearchPage extends HookConsumerWidget {
) )
.toList(); .toList();
return KeyboardListener( return AutoComplete(
focusNode: focusNode,
autofocus: true,
onKeyEvent: (value) {
final isEnter = value.logicalKey ==
LogicalKeyboardKey.enter;
if (isEnter) {
onSubmitted(controller.text);
focusNode.unfocus();
}
},
child: AutoComplete(
suggestions: suggestions.length <= 2 suggestions: suggestions.length <= 2
? [ ? [
...suggestions, ...suggestions,
@ -153,6 +142,7 @@ class SearchPage extends HookConsumerWidget {
child: TextField( child: TextField(
autofocus: true, autofocus: true,
controller: controller, controller: controller,
focusNode: focusNode,
features: [ features: [
const InputFeature.leading( const InputFeature.leading(
Icon(SpotubeIcons.search), Icon(SpotubeIcons.search),
@ -182,7 +172,6 @@ class SearchPage extends HookConsumerWidget {
placeholder: Text(context.l10n.search), placeholder: Text(context.l10n.search),
onSubmitted: onSubmitted, onSubmitted: onSubmitted,
), ),
),
); );
}), }),
), ),