滚动可滚动窗口小部件

时间:2019-04-19 17:26:58

标签: dart flutter

我有一个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);
            },
          );
        },
      ),
    );
  }

Here is a video of the problem

1 个答案:

答案 0 :(得分:0)

我认为您需要将SliverAppBar()小部件与TabBar()一起使用。

Here's a resource that might help you