flutter 动态 修改 AppBar 中 高度 内容 是否显示等

直接 用要刷新的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,
    ),
  ),
);
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值