dart – 如何在flutter中创建工具栏搜索视图

dart – 如何在flutter中创建工具栏搜索视图,第1张

概述我需要在我的app工具栏中实现searchview来实现列表视图列表过滤器.像下面的图像,我搜索很多仍然没有得到正确的答案.任何帮助将不胜感激,谢谢你提前 只需用户点击图标,您就需要在状态之间切换.除了一点点重构代码清理之外,这个简单的例子可以让你前进. class SearchAppBar extends StatefulWidget { @override _SearchAppBarS 我需要在我的app工具栏中实现searchvIEw来实现列表视图列表过滤器.像下面的图像,我搜索很多仍然没有得到正确的答案.任何帮助将不胜感激,谢谢你提前

解决方法 只需用户点击图标,您就需要在状态之间切换.除了一点点重构代码清理之外,这个简单的例子可以让你前进.

class SearchAppbar extends StatefulWidget {  @overrIDe  _SearchAppbarState createState() => new _SearchAppbarState();}class _SearchAppbarState extends State<SearchAppbar> {  Widget appbarTitle = new Text("Appbar Title");  Icon actionIcon = new Icon(Icons.search);  @overrIDe  Widget build(BuildContext context) {    return new Scaffold(      appbar: new Appbar(        centerTitle: true,Title:appbarTitle,actions: <Widget>[          new Iconbutton(icon: actionIcon,onpressed:(){          setState(() {                     if ( this.actionIcon.icon == Icons.search){                      this.actionIcon = new Icon(Icons.close);                      this.appbarTitle = new TextFIEld(                        style: new TextStyle(                          color: colors.white,),decoration: new inputdecoration(                          prefixIcon: new Icon(Icons.search,color: colors.white),hintText: "Search...",hintStyle: new TextStyle(color: colors.white)                        ),);}                      else {                        this.actionIcon = new Icon(Icons.search);                        this.appbarTitle = new Text("Appbar Title");                      }                    });        },]      ),);  }}
总结

以上是内存溢出为你收集整理的dart – 如何在flutter中创建工具栏搜索视图全部内容,希望文章能够帮你解决dart – 如何在flutter中创建工具栏搜索视图所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1003388.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存