From ef92bea1cc85c253d80ccdd964fcd5b58def9f58 Mon Sep 17 00:00:00 2001 From: Ty Irvine <39813066+tyirvine@users.noreply.github.com> Date: Thu, 9 Apr 2020 17:41:04 -0400 Subject: [PATCH] Smoother Animation Hi, I am Ty. I love this package that you built! I'm currently incorporating it into my app. It's amazing. Thank you for making it. I made some other changes to this but I figured I could say thank you by adding this in. I imagine the animation as it is, is intentional but maybe it wasn't. Anyways, please check it out :) Review of Changes -------------------- 1. Prevent cancellationWidget text from truncating and giving it a fade option - (maybe this could be a user specified option) 2. Smoothed out hide animation by removing _animate - (was there a reason for this?) 3. Added padding and adjusted container width to suit the new changes Thanks again! I hope you are doing well with COVID-19 --- lib/flappy_search_bar.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/flappy_search_bar.dart b/lib/flappy_search_bar.dart index 691742f..25af294 100644 --- a/lib/flappy_search_bar.dart +++ b/lib/flappy_search_bar.dart @@ -232,7 +232,7 @@ class SearchBar extends StatefulWidget { this.hintStyle = const TextStyle(color: Color.fromRGBO(142, 142, 147, 1)), this.iconActiveColor = Colors.black, this.textStyle = const TextStyle(color: Colors.black), - this.cancellationWidget = const Text("Cancel"), + this.cancellationWidget = const Text("Cancel", overflow: TextOverflow.fade, maxLines: 1, softWrap: false), this.onCancelled, this.suggestions = const [], this.buildSuggestion, @@ -418,15 +418,18 @@ class _SearchBarState extends State> child: AnimatedOpacity( opacity: _animate ? 1.0 : 0, curve: Curves.easeIn, - duration: Duration(milliseconds: _animate ? 1000 : 0), + duration: Duration(milliseconds: 500), child: AnimatedContainer( duration: Duration(milliseconds: 200), width: - _animate ? MediaQuery.of(context).size.width * .2 : 0, + _animate ? MediaQuery.of(context).size.width * .15 : 0, child: Container( color: Colors.transparent, child: Center( - child: widget.cancellationWidget, + child: Padding( + padding: const EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 0.0), + child:widget.cancellationWidget, + ), ), ), ),