提交 79b2f474 authored 作者: maodou's avatar maodou

1:修复 搜索页点击历史搜索未进行搜索的问题

上级 586ac1e7
......@@ -6,7 +6,7 @@ class SearchController extends GetxController {
controlFinishRefresh: true,
);
late TextEditingController searchController = TextEditingController();
bool showHistory = true;
// 搜索记录数组
List<String> records = [];
// 书籍数组
......
......@@ -8,7 +8,6 @@ class SearchPage extends StatefulWidget {
}
class _SearchPageState extends State<SearchPage> {
bool showHistory = true; // 根据条件设置为true或false
@override
Widget build(BuildContext context) {
return GetBuilder<SearchController>(
......@@ -27,7 +26,7 @@ class _SearchPageState extends State<SearchPage> {
// context.pushNamed(Routes.msgs);
},
onEditingComplete: () {
showHistory = false;
controller.showHistory = false;
controller.search();
// FocusScope.of(context).unfocus();
FocusNode blankNode = FocusNode();
......@@ -57,7 +56,7 @@ class _SearchPageState extends State<SearchPage> {
}
Widget buildListView(SearchController controller) {
if (showHistory) {
if (controller.showHistory) {
// 如果条件为true,显示历史搜索记录
return BuildHistory(controller: controller);
} else {
......
......@@ -2,7 +2,6 @@ part of search;
class BuildHistory extends StatefulWidget {
final SearchController controller;
const BuildHistory({
Key? key,
required this.controller,
......@@ -65,6 +64,13 @@ class _BuildHistoryState extends State<BuildHistory> {
}else {
return searchList.map((e){
return GestureDetector(
onTap: () {
// showHistory = false;
widget.controller.searchController.text =e;
widget.controller.showHistory = false;
widget.controller.search();
Console.log('点击了-$e');
},
child: Container(
height: 27,
decoration: BoxDecoration(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论