首页 > 解决方案 > 滚动可滚动小部件时,列内的小部件未完全滚动

问题描述

我有一个NestedScrollView它的身体包含一个TabBarView. 其中一个选项卡有一个带有图像的列和一个可滚动的小部件(GridView.builder)。滚动此可滚动小部件时,图像会卡在中途(就好像它被固定在那个位置一样)。

这是代码

//home.dart

class _HomePage extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Container(                //this is the image that gets stuck
      child: Column(
        children: <Widget>[
          new Container(
            child: new Image.asset(
              "images/product.jpg",
              fit: BoxFit.fitWidth,
            ),
          ),
          Expanded(
            child: FreshFinds(),    //this is the scrollable widget
          ),
        ],
      ),
    );
  }
}

// Freshfind.dart 

  @override
  Widget build(BuildContext context) {
    return Card(
      child: GridView.builder(
        // shrinkWrap: true,
        itemCount: 50,
        physics: ScrollPhysics(),
        gridDelegate:
            new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
        itemBuilder: (BuildContext context, int index) {
          return FutureBuilder(
            future: fetchdata(index),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (!snapshot.hasData)
                return buildfake(index);
              else
                return buildcard(snapshot.data, index);
            },
          );
        },
      ),
    );
  }

这是问题的视频

标签: dartflutter

解决方案


我认为您需要将SliverAppBar()小部件与TabBar().

这是一个可能对您有帮助的资源


推荐阅读