【问题标题】:How to remove empty space below tab.. FLUTTER如何删除选项卡下方的空白空间.. 颤振
【发布时间】:2021-01-17 17:48:54
【问题描述】:

这是我的代码实现:

return Scaffold(
        appBar: CustomAppBar(
          scaffoldKey: widget.scaffoldKey,
          // icon: AppIcon.settings,
          // onActionPressed: onSettingIconPressed,
          onSearchChanged: (text) {
            setState(() {
              if (text.length > 0) {
                searching = true;
              } else {
                searching = false;
              }
            });
            state.filterByUsername(text);
          },
        ),
        backgroundColor: Colors.white,
        body:
            // Column(children: [
            RefreshIndicator(
                backgroundColor: Colors.white,
                onRefresh: () async {
                  HapticFeedback.selectionClick();
                  setState(() {
                    list3 = state2.getTweetList(authstate.userModel);
                    list3.shuffle();
                    onlyImages.shuffle();
                  });
                  state.getDataFromDatabase();
                  return Future.value(true);
                },

                // mesto povise greed, i ispod search boxa
                child: Column(
                  children: <Widget>[
                    CarouselSlider.builder(
                      itemCount: images.length,
                      options: CarouselOptions(
                        // autoPlayInterval: Duration(milliseconds: 30),
                        autoPlay: true,
                        aspectRatio: 2.0,
                        enlargeCenterPage: true,
                      ),
                      itemBuilder: (context, index) {
                        return Container(
                          child: Center(
                            child: (imageUrl != null)
                                ? Image.network(imageUrl)
                                : Placeholder(
                                    fallbackHeight: 200,
                                    fallbackWidth: double.infinity,
                                  ),

                            // Center(
                            //     child: Image.network(images[index],
                            //         fit: BoxFit.cover, width: 1000)
                          ),
                        );
                      },
                    ),
                    SizedBox(
                      height: 5,
                    ),
                    Expanded(
                      // flex: 1,
                      child: CustomScrollView(slivers: <Widget>[
                        SliverToBoxAdapter(
                            child: Container(
                                padding: EdgeInsets.only(top: 0),
                                height: 30,
                                margin: EdgeInsets.only(top: 5, bottom: 5),
                                child: ListView(
                                    scrollDirection: Axis.horizontal,
                                    children: <Widget>[
                                      _tagItem('#DAJGI'),
                                      _tagItem('#Advertisements'),
                                      _tagItem('Animal'),
                                      _tagItem('Travel'),
                                      _tagItem('Happy'),
                                      _tagItem(
                                        'Art',
                                      ),
                                    ]))),
                      ]),
                    ),
                    searching
                        ? ListView.separated(
                            addAutomaticKeepAlives: false,
                            physics: BouncingScrollPhysics(),
                            itemBuilder: (context, index) =>
                                _UserTile(user: list[index]),
                            separatorBuilder: (_, index) => Divider(
                              color: Colors.transparent,
                              height: 0,
                            ),
                            itemCount: list?.length ?? 0,
                          )
                        : Expanded(
                            child: GridView.count(
                              crossAxisCount: 3,
                              children:
                                  List.generate(onlyImages.length, (index) {
                                return GestureDetector(
                                    onTap: () {
                                      FeedModel model = onlyImages[index];
                                      onTweetPressed(context, model);
                                    },
                                    onLongPress: () {
                                      _createPopupContext;
                                      FeedModel model = onlyImages[index];
                                      onTweetPressed(context, model);
                                    },
                                    child: Container(
                                      child: Card(
                                          child: onlyImages
                                                      .elementAt(index)
                                                      .imagesPath
                                                      .length >
                                                  0
                                              ? CachedNetworkImage(
                                                  imageUrl: onlyImages
                                                      .elementAt(index)
                                                      .imagesPath[0],
                                                  fit: BoxFit.cover,
                                                )
                                              :
                                              //Container()
                                              Center(
                                                  child: Text(onlyImages
                                                      .elementAt(index)
                                                      .description),
                                                )),
                                    ));
                              }),
                            ),
                          ),
                  ],
                )))

结果:

【问题讨论】:

    标签: android ios flutter dart scaffold


    【解决方案1】:

    您好,在您的专栏中,您有 2 个扩展小部件,因此您的标签可以获得更多空间;

    column(
      children:[
         CarouselSlider
         Expanded(
            // flex: 1,
            child: CustomScrollView // Your Tags )
         Expanded(
            child: GridView.count(  // Your Grid)
      ]
    )
    

    现在您可以删除 ExpandedCustomScrollViewSliverToBoxAdapter

    并使您的专栏如下所示

    column(
      children:[
         CarouselSlider
         Container(  // Your Tags )
         Expanded(
            child: GridView.count(  // Your Grid)
      ]
    )
    

    【讨论】:

    • 问题是当我将“CustomScrollView”放在其他一些小部件中时,我看不到滚动“_tag items”,但是当我放入展开的小部件时,我可以看到正常的“_tagItems”,但在这种情况下我有这个空的空间...
    猜你喜欢
    • 1970-01-01
    • 2021-11-20
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    相关资源
    最近更新 更多