gpt4 book ai didi

flutter 动画 : showSearch with opencontainer

转载 作者:行者123 更新时间:2023-12-05 06:15:59 25 4
gpt4 key购买 nike

在Flutter的animations包中,使用Container变换动画的案例之一是

A search bar into expanded search

现在显示扩展搜索的常用方法是使用 showSearch 函数,而我唯一知道的修改搜索动画的方法是通过搜索代理。

有什么方法可以将 openContainershowSearch 一起使用吗?或者我应该创建自己的搜索页面以使用 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>\packages\flutter\lib\src\material\search.dart(Ex:
E:\software\flutter\packages\flutter\lib\src\material\search.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,
// );

如果您想将标签从“搜索”更改为您的自定义标签在您使用 SearchDelegate 扩展的类中提供标签在 super() 中作为属性 searchFieldLabel

  To Change the Label :
class StoreSearch extends SearchDelegate<String> {
// @override
// TODO: implement searchFieldLabel
StoreSearch()
: super(
searchFieldLabel: "StoreSearch",//provide your Label here
);}

关于 flutter 动画 : showSearch with opencontainer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62273813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com