在 Flutter 的animations
包中,使用 Container 变换动画的一个案例示例是
展开搜索的搜索栏
现在显示扩展搜索的常用方法是使用showSearch
函数,我在修改搜索动画时唯一知道的就是通过搜索委托。
有没有办法将openContainer
与showSearch
一起使用?还是我应该创建自己的搜索页面以使用openContainer
打开,而不是依赖showSearch
?
Here I found a Solution that may be complex because in our SearchDelegate we can't
implement animation implicitly.
We can change the package provided by flutter. GoTO
<Flutter Sdk Path>packagesflutterlibsrcmaterialsearch.dart(Ex:
E:softwareflutterpackagesflutterlibsrcmaterialsearch.dart)
enter code here
Inside Official Search.dart we can make changes accordingly...
Here what I have done to change the animation Duration and type of Animation itself...
To change the animation DUration: line no 341
Duration get transitionDuration => const Duration(milliseconds: 700);//give your
// flexible number
To change the animation : line no 353
return your own animation type default there will be FadeTransition from line No 353-356 you can use SlideTransition, ScaleTransition in the place of FadeTransition
return SlideTransition( //for slide transition return this instead of Fade
//Animation
position: Tween<Offset>(
begin: const Offset(0, -0.5),
end: Offset.zero,
).animate(animation),
child: child,
);
// ScaleTransition( //for scale transition uncomment this(ZoomIn and Zoom out)
// scale: Tween<double>(
// begin: 0.0,
// end: 1.0,
// ).animate(
// CurvedAnimation(
// parent: animation,
// curve: Curves.fastOutSlowIn,
// ),
// ),
// child: child,
// );
如果要将标签从"搜索"更改为"自定义标签" 在已使用搜索委托扩展的类中提供标签 inside super(( as property searchFieldLabel
To Change the Label :
class StoreSearch extends SearchDelegate<String> {
// @override
// TODO: implement searchFieldLabel
StoreSearch()
: super(
searchFieldLabel: "StoreSearch",//provide your Label here
);}