From 806b34f0922c642e488ab8476f670af195c2d19d Mon Sep 17 00:00:00 2001 From: xsahil03x Date: Wed, 25 Nov 2020 16:59:54 +0530 Subject: [PATCH] minor changes --- example/lib/search_text_field.dart | 42 ++++++++++++++++-------------- lib/src/stream_svg_icon.dart | 12 +++++++++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/example/lib/search_text_field.dart b/example/lib/search_text_field.dart index 7fcd3727..8461d735 100644 --- a/example/lib/search_text_field.dart +++ b/example/lib/search_text_field.dart @@ -6,6 +6,7 @@ class SearchTextField extends StatelessWidget { final ValueChanged onChanged; final String hintText; final VoidCallback onTap; + final bool showCloseButton; const SearchTextField({ Key key, @@ -13,6 +14,7 @@ class SearchTextField extends StatelessWidget { this.onChanged, this.onTap, this.hintText = 'Search', + this.showCloseButton = true, }) : super(key: key); @override @@ -55,25 +57,27 @@ class SearchTextField extends StatelessWidget { ), ), ), - // Material( - // - // child: IconButton( - // icon: StreamSvgIcon.close( - // color: Colors.grey, - // ), - // splashRadius: 24, - // onPressed: () { - // if (controller.text.isNotEmpty) { - // Future.microtask( - // () => [ - // controller.clear(), - // onChanged(''), - // ], - // ); - // } - // }, - // ), - // ), + if (showCloseButton) + Material( + color: Colors.transparent, + child: IconButton( + padding: const EdgeInsets.all(0), + icon: StreamSvgIcon.close_small( + color: Colors.grey, + ), + splashRadius: 24, + onPressed: () { + if (controller.text.isNotEmpty) { + Future.microtask( + () => [ + controller.clear(), + onChanged(''), + ], + ); + } + }, + ), + ), ], ), ); diff --git a/lib/src/stream_svg_icon.dart b/lib/src/stream_svg_icon.dart index 894b868a..1b0c9ae9 100644 --- a/lib/src/stream_svg_icon.dart +++ b/lib/src/stream_svg_icon.dart @@ -387,4 +387,16 @@ class StreamSvgIcon extends StatelessWidget { height: size, ); } + + factory StreamSvgIcon.close_small({ + double size, + Color color, + }) { + return StreamSvgIcon( + assetName: 'Icon_close_sml.svg', + color: color, + width: size, + height: size, + ); + } }