Ver Fonte

fire ClearAndUnfocusSearchBar instead of findingAncestorStateObject with textController and focusNode to clear and unfocus search bar

ashilkn há 1 ano atrás
pai
commit
8f0ab0d597
1 ficheiros alterados com 3 adições e 5 exclusões
  1. 3 5
      lib/ui/viewer/search/search_suffix_icon_widget.dart

+ 3 - 5
lib/ui/viewer/search/search_suffix_icon_widget.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/clear_and_unfocus_search_bar_event.dart";
 import "package:photos/theme/ente_theme.dart";
-import 'package:photos/ui/viewer/search/search_widget.dart';
 
 class SearchSuffixIcon extends StatefulWidget {
   final bool shouldShowSpinner;
@@ -35,10 +36,7 @@ class _SearchSuffixIconState extends State<SearchSuffixIcon>
               splashRadius: 1,
               visualDensity: const VisualDensity(horizontal: -1, vertical: -1),
               onPressed: () {
-                final searchWidgetState =
-                    context.findAncestorStateOfType<SearchWidgetState>()!;
-                searchWidgetState.textController.clear();
-                searchWidgetState.focusNode.unfocus();
+                Bus.instance.fire(ClearAndUnfocusSearchBar());
               },
               icon: Icon(
                 Icons.close,