直接 用要刷新的provide 控件或者其他控制 包裹 Scaffold 我这里用的 是 Getx这个三方状态管理的控件
return Obx(
() => Scaffold(
appBar: PreferredSize(
preferredSize:
Size(MediaQuery.of(context).size.width, homeSearchController.isNeedHideAppbar.value ? 45.h : 80.h),
child: Obx(
() => AppBar(
centerTitle: false,
elevation: 0,
backgroundColor: ZColors.colorWhite,
//去除lead宽度
titleSpacing: 0,
automaticallyImplyLeading: false,
title: homeSearchController.isNeedHideAppbar.value
? Container(height: 1)
: Row(
children: [
SizedBox(width: 17.w),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 14.w),
height: 30.h,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6.w),
border: new Border.all(color: Color(0xFFFC433D), width: 0.5),
),
child: Row(
children: [
Container(
padding: EdgeInsets.only(
top: 1,
),
child: Icon(
CupertinoIcons.search,
color: ZColors.textGreyB7B7B7,
size: 16.5,
),
),
SizedBox(
width: 5.w,
),
Expanded(
child: Container(
child: TextField(
controller: textEditingController,
keyboardType: TextInputType.text,
style: pingFangM(12,
color: Color(0xff888888), textBaseline: TextBaseline.alphabetic),
cursorColor: ZColors.textColor,
//focusNode: nameFocusNode,
textInputAction: TextInputAction.search,
onSubmitted: (text) {
textEditingController.text = text.trim();
// if (textEditingController.text.length == 0) {
// return JMToast.show("请输入搜索内容!");
// }
if (!homeSearchController.searchHistory.contains(text.trim()) &&
textEditingController.text.length != 0) {
homeSearchController.searchHistory.add(text);
SharedPreferencesUtils().saveString(ShaPreKey().shopSearchHistory,
homeSearchController.searchHistory.join(","));
}
eventBus.fire(SearchSourceEvent(searchKey: text, searchType: searchType));
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: "鸡排加盟",
hintStyle: pingFangM(12, color: Color(0xFFCCCCCC)),
contentPadding: EdgeInsets.only(bottom: 15.w),
),
),
),
)
],
),
),
),
InkWell(
onTap: () => Get.back(),
child: Container(
margin: EdgeInsets.only(right: 17.w, left: 9),
child: Text(
'取消',
style: pingFangB(12.sp, color: ZColors.text333333),
),
),
)
],
),
bottom: PreferredSize(
preferredSize: Size.fromHeight(45.h),
child: Container(
color: Colors.white,
child: TabBar(
//生成Tab菜单
isScrollable: true,
indicatorWeight: 3,
indicatorSize: TabBarIndicatorSize.label,
indicator: UnderlineTabIndicatorCopy(
indicatorWidth: 16.w,
insets: EdgeInsets.all(0.w),
borderSide: BorderSide(width: 3.w, color: Color(0xFFE60012))),
indicatorColor: ZColors.primaryColor,
labelColor: ZColors.primaryColor,
unselectedLabelColor: ZColors.textColor,
unselectedLabelStyle: pingFangM(15),
labelStyle: pingFangB(18),
controller: _tabController,
tabs: titleItems.map((item) {
return Tab(text: item);
}).toList(),
),
),
),
),
)),
body: TabBarView(
children: bodyItems,
controller: _tabController,
),
),
);