小编JC2*_*C23的帖子

GridView.builder创建无限滚动的页面

尝试使用API​​来构建网格.一切都很好,但在最后一排瓷砖之后,页面变成空白,只是保持滚动和滚动......网格就像这样构建:

body: new GridView.builder(
      gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3),
      itemBuilder: (BuildContext context, int index) {
        return new Card(
          child: new GridTile(
            footer: new Text(data[index]['name']),
              child: new Text(data[index]['image']), //just for testing, will fill with image later
          ),
        );
      },
  )
Run Code Online (Sandbox Code Playgroud)

例外情况是我不断向下滚动空白页面,最后一个数字(包括:24)变大2倍(24,26,28等)的倍数.

I/flutter (11001): Another exception was thrown: RangeError (index): Invalid value: Not in range 0..23, inclusive: 24
Run Code Online (Sandbox Code Playgroud)

有人看过GridView.builder的这种行为吗?

dart flutter

9
推荐指数
1
解决办法
1万
查看次数

ExoPlayer2-如何从片段释放

我有一个带有2个片段的活动(不是ViewPager),并且想在其中一个片段中使用ExoPlayer2播放内容。最初的片段显示了一个内容列表,单击时显示了第二个片段,以播放选定的内容。但是,当我单击返回到初始片段时,仍然可以听到内容的播放。好像第二个片段仍然打开。我正在(尝试)通过这种方式释放播放器:

@Override
public void onStop() {
    super.onStop();
    releasePlayer();
}

public void releasePlayer() {

    if (player != null) {
        player.setPlayWhenReady(true);
        player.stop();
        player.release();
        player = null;
        trackSelector = null;
        simpleExoPlayerView.setPlayer(null);
        simpleExoPlayerView = null;
        System.out.println("releasePlayer");
    }
}
Run Code Online (Sandbox Code Playgroud)

我读了这篇文章,但是并没有提供很多解决方案。另外,请阅读几篇在ViewPager片段中使用ExoPlayer的文章,但不能完全确定这些示例如何释放播放器。遵循此处演示应用程序中的releasePlayer()方法,但没有运气。从onPause(),onDetach(),onDestroyView()调用releasePlayer(),但没有区别。

这是在将侦听器添加到播放器之后设置的一些日志记录,但是没有看到任何解释它为什么不释放的信息...

07-05 19:01:07.216 2529-2643/? V/RenderScript: 0xe0494000 Launching thread(s), CPUs 4
07-05 19:01:11.871 3064-3064/? V/MediaCodecInfo: Listener-onPlayerStateChanged...
07-05 19:01:11.876 3064-3064/? V/MediaCodecInfo: Listener-onPlayerStateChanged...
07-05 19:01:11.904 3064-3064/? V/MediaCodecInfo: Listener-onPlayerStateChanged...
07-05 19:01:11.904 3064-3064/? V/MediaCodecInfo: Listener-onTimelineChanged...
07-05 19:01:11.904 3064-3064/? V/MediaCodecInfo: Listener-onLoadingChanged...
07-05 19:01:11.904 3064-3064/? V/MediaCodecInfo: Listener-onPlayerStateChanged...
07-05 …
Run Code Online (Sandbox Code Playgroud)

android android-fragments exoplayer2.x

6
推荐指数
1
解决办法
2441
查看次数

Flutter - How to get Container with children to take up entire screen

As per Flutter docs Containers with no children try to be as big as possible unless the incoming constraints are unbounded, in which case they try to be as small as possible. Containers with children size themselves to their children. The closest I've been to getting it to work:

return Stack(
  children: <Widget>[
    Container(
      width: MediaQuery.of(context).size.width,
      height: MediaQuery.of(context).size.height,
      //width: Device.screenWidth,
      //height: Device.screenHeight,
      child: Column(
        children: <Widget>[(view[1])],
      ),
    ),
    Container(
      width: MediaQuery.of(context).size.width * .50,
      height: MediaQuery.of(context).size.width * .50,
      child: Column(
        children: …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

4
推荐指数
3
解决办法
5550
查看次数

AWS Lambda函数-无法调用更新事物影子

根据此处的 boto3 文档: https: //boto3.readthedocs.org/en/latest/reference/services/iot-data.html#client update_thing_shadow 方法将 thingName 和 JSON 负载作为参数。目前内容如下:

    client = boto3.client('iot-data', region_name='us-east-1')
    data = {"state" : { "desired" : { "switch" : "on" }}}
    mypayload = json.dumps(data)
    response = client.update_thing_shadow(
        thingName = 'MyDevice', 
        payload = b'mypayload'
    )
Run Code Online (Sandbox Code Playgroud)

当我使用命令行时没有问题,但似乎无法从巴函数中得到它。我用许多版本的代码(json.JSONEncoder、bytearray() 等)调用它,但没有任何运气。调用 UpdateThingShadow 操作时,错误范围从语法到 (ForbiddenException):Bad Request: ClientError。有没有人成功地从 AWS lambda 函数中调用此方法或类似方法?谢谢。

json amazon-web-services boto3 aws-lambda aws-iot

3
推荐指数
1
解决办法
4395
查看次数

Flutter - 未定义命名参数

尝试按照此处使用的代码创建列表,但无法解决语法错误

class _ContactListItem extends ListView {

  _ContactListItem(Contact contact) :
    super(
      title : new Text(contact.fullName),
      subtitle: new Text(contact.email),
      leading: new CircleAvatar(child: new Text(contact.fullName[0]))
  );

}
Run Code Online (Sandbox Code Playgroud)

错误是“未定义命名参数‘标题’。” 副标题和前导也存在相同的错误(我认为修复一个可能会解决所有问题)。对于 flutter 和 dart 来说是全新的,所以欢迎任何反馈。

dart flutter

2
推荐指数
1
解决办法
5万
查看次数