icon: Icon(Icons.search), onPressed: (){ showSearch(context: context,delegate: SearchBarDelegate()); }, ) ], ), ); } }classSearchBarDelegate extends SearchDelegate<String>{//清空按钮@override List<Widget>buildActions(BuildContext context){return[ IconButton( icon: Icon(Icons.clear), onPressed...
icon: Icon(Icons.search), onPressed: (){ print('搜索按钮被点击了'); showSearch(context: context,delegate: SeachBarDelegate()); } ) ], ), ); } } assets.dart constsearchSuggestions =['政治新闻','娱乐新闻','体育新闻','技术知识'];constsearchList =['Flutter基础','Flutter进阶','Flutter...
label:'Home',),BottomNavigationBarItem(icon:Icon(Icons.search),label:'Search',),BottomNavigationBarItem(icon:Icon(Icons.person),label:'Profile',),],currentIndex:_selectedIndex,selectedItemColor:Colors.blue,// 更改选中项的颜色selectedIconTheme:IconThemeData(size:30),// 更改选中项的图标大小...
appBar:AppBar(centerTitle:true,title:Text("用户中心"),//定义顶部导航栏的左侧按钮leading:IconButton(icon:Icon(Icons.menu),onPressed:()=>print("menu"),),//定义顶部导航栏的右侧按钮组actions:<Widget>[IconButton(icon:Icon(Icons.search),onPressed:()=>print("search"),),IconButton(icon:Icon(Ic...
Icon(Icons.search, color: Colors.grey), SizedBox(width: 3), Text("搜索", style: TextStyle(fontSize: 16, color: Colors.grey)) ], ), ), ), ), const SizedBox(height: 10), GestureDetector( onTap: () { Get.to(const UserDevicePage(), ...
@overrideList<Widget>buildActions(BuildContext context){return[IconButton(icon:Icon(Icons.clear),onPressed:()=>query="",)];} 当我们点击右侧删除button 触发 onPressed 方法我们把输入框内容置空 buildLeading 方法左侧返回键方法 @override WidgetbuildLeading(BuildContext context){returnIconButton(icon:Animate...
在之前的学习中自己实现了了一个搜索界面,其中自定义了搜索栏,实现效果也就将就,后来发现在Flutter中有现成的控件可以使用,也就是SearchDelegate<T>,调用showSearch(context: context, delegate: searchBarDelegate())实现。 2.定义SearchDelegate classsearchBarDelegateextendsSearchDelegate<String>{@overrideList<Widget>buil...
prefixIcon: const Icon(Icons.search), //头部搜索图标 filled: true, fillColor: Colors.grey.withAlpha(50), // 设置输入框背景色为灰色,并设置透明度 hintText: "Search people", hintStyle: const TextStyle(color: Colors.grey, fontSize: 14), ...
appBar: AppBar(title: _buildAppBarTitle(),centerTitle: true,actions: [IconButton(icon: Icon(Icons.search),onPressed: _showSearchPage,),PopupMenuButton<String>(itemBuilder: (context) => [PopupMenuItem(child: Text('发起群聊'),value: '发起群聊',),PopupMenuItem(child: Text('添加朋友'),...
activeIcon: Icon(CupertinoIcons.home,color: Colors.pink,), label:"首页", ), BottomNavigationBarItem( icon: Icon(CupertinoIcons.search,color: Colors.grey,), activeIcon: Icon(CupertinoIcons.search,color: Colors.pink,), label:"手册",