Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 带有未来Json数据的颤振狭长列表_Flutter_Flutter Sliver - Fatal编程技术网

Flutter 带有未来Json数据的颤振狭长列表

Flutter 带有未来Json数据的颤振狭长列表,flutter,flutter-sliver,Flutter,Flutter Sliver,我在尝试使用JSON API响应的子项填充SliverFixedExtentList时遇到了一个问题。我有一个函数\u getMyListOfCustomJsonObjects(),它返回一个未来>。我对flatter还比较陌生,但我对SliverLists的理解是,它们的行为应该与列表视图类似。我已经能够使用FutureBuilder和ListView.builder来填充这些孩子的ListView。但是,更改SliverList会给我带来一个错误 下面是我的代码示例 CustomScroll

我在尝试使用JSON API响应的子项填充
SliverFixedExtentList
时遇到了一个问题。我有一个函数
\u getMyListOfCustomJsonObjects()
,它返回一个
未来>
。我对flatter还比较陌生,但我对
SliverLists
的理解是,它们的行为应该与
列表视图
类似。我已经能够使用
FutureBuilder
ListView.builder
来填充这些孩子的
ListView
。但是,更改
SliverList
会给我带来一个错误

下面是我的代码示例

CustomScrollView(
   slivers: [
SliverAppBar(),
FutureBuilder(
  future: _getMyListOfCustomJsonObjects,
  builder: (BuildContext context, AsyncSnapshot snapshot) {
    if (snapshot.data != null)
      return SliverFixedExtentList(
        itemExtent: 150,
        delegate: SliverChildBuilderDelegate(
            (BuildContext context, int index) {
          return
           Container(
           color: Colors.red, 
           child: Text('${snapshot.data[index].Name}'));
        }, 
         childCount: snapshot.data.length),
      );
    else {
      return Padding(
        padding: EdgeInsets.only(top:50),
        //alignment: Alignment.center,
        child: Stack(
          alignment: Alignment.bottomCenter,
          children: <Widget>[
            new CircularProgressIndicator(
              value: null,
              strokeWidth: 4,
              backgroundColor: Color(0xFFe5ac3b),
              semanticsLabel: "Loading",
              valueColor:
                  new AlwaysStoppedAnimation<Color>(Color(0xFF12336c)),
            ),
          ],
        ),
      );
    }
  },
),
],
),

关于使用
Future
填充
SliverList
的任何建议?

您能提供整个堆栈跟踪吗?在你提到的那些异常之前似乎有一个异常,因为它们都说“抛出了另一个异常”。好吧,在对堆栈跟踪做了更多的挖掘之后,我发现是Else{}的内容给了我接收到的错误。为了解决这个问题,我在Else{}中使用了SliverFillRemaining()-但是,异步快照似乎返回null。这与小部件的构建时间有关吗?
flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true. 

flutter: Another exception was thrown: Duplicate GlobalKeys detected in widget tree.