@@ -52,7 +52,8 @@ class HomePage extends StatefulWidget {
5252
5353class _HomePageState extends State <HomePage > {
5454 final addKey = GlobalKey ();
55- final searchKey = GlobalKey ();
55+ final searchKey1 = GlobalKey ();
56+ final searchKey2 = GlobalKey ();
5657 final filterKey = GlobalKey ();
5758 final menuKey = GlobalKey ();
5859 final refreshKey = GlobalKey ();
@@ -64,7 +65,7 @@ class _HomePageState extends State<HomePage> {
6465 tutorialCoachMark = TutorialCoachMark (
6566 targets: addTargetsPage (
6667 addKey: addKey,
67- searchKey: searchKey ,
68+ searchKey: searchKey1 ,
6869 filterKey: filterKey,
6970 menuKey: menuKey,
7071 refreshKey: refreshKey,
@@ -206,7 +207,7 @@ class _HomePageState extends State<HomePage> {
206207 Text ('Home Page' , style: GoogleFonts .poppins (color: Colors .white)),
207208 actions: [
208209 IconButton (
209- key: searchKey ,
210+ key: searchKey1 ,
210211 icon: (storageWidget.searchVisible)
211212 ? const Tooltip (
212213 message: 'Cancel' ,
@@ -278,7 +279,7 @@ class _HomePageState extends State<HomePage> {
278279 children: < Widget > [
279280 if (storageWidget.searchVisible)
280281 Container (
281- key: searchKey ,
282+ key: searchKey2 ,
282283 margin: const EdgeInsets .symmetric (
283284 horizontal: 10 , vertical: 10 ),
284285 child: SearchBar (
@@ -287,6 +288,7 @@ class _HomePageState extends State<HomePage> {
287288 onChanged: (value) {
288289 storageWidget.search (value);
289290 },
291+
290292 shape: MaterialStateProperty .resolveWith <OutlinedBorder ?>(
291293 (Set <MaterialState > states) {
292294 if (states.contains (MaterialState .focused)) {
@@ -305,6 +307,24 @@ class _HomePageState extends State<HomePage> {
305307 },
306308 ),
307309 leading: const Icon (Icons .search_rounded),
310+ trailing: < Widget > [
311+ (storageWidget.searchController.text.isNotEmpty)
312+ ? IconButton (
313+ key: GlobalKey (),
314+ icon: const Icon (Icons .cancel,
315+ color: Colors .black),
316+ onPressed: () {
317+ storageWidget.searchController.clear ();
318+ storageWidget.search (
319+ storageWidget.searchController.text);
320+ },
321+ )
322+ : const SizedBox (
323+ width: 0 ,
324+ height: 0 ,
325+ )
326+ ],
327+
308328 hintText: 'Search' ,
309329 ),
310330 ),
0 commit comments