首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Uint8List在FutureBuilder中的颤振产生误差

Uint8List在FutureBuilder中的颤振产生误差
EN

Stack Overflow用户
提问于 2021-03-06 09:00:48
回答 2查看 3.1K关注 0票数 2

我正在从这个参考颤振图片库构建一个颤振图库应用程序

一切正常,但我在Future Builder中遇到了错误

,这是我收到的错误警告

代码语言:javascript
复制
The name 'Uint8List' isn't a type so it can't be used as a type argument.
Try correcting the name to an existing type, or defining a type named 'Uint8List'.

,这是我得到的运行时错误

代码语言:javascript
复制
Error: 'Uint8List' isn't a type.
    return FutureBuilder<Uint8List>(
                         ^^^^^^^^^

这个Uint8List对我来说是全新的概念,我不知道该怎么做。

--这是返回未来生成器的小部件

代码语言:javascript
复制
  @override
  Widget build(BuildContext context) {
    // We're using a FutureBuilder since thumbData is a future
    return FutureBuilder<Uint8List>(
      future: asset.thumbData,
      builder: (_, snapshot) {
        final bytes = snapshot.data;
        // If we have no data, display a spinner
        if (bytes == null) return CircularProgressIndicator();
        // If there's data, display it as an image
        return InkWell(
          onTap: () {
            // TODO: navigate to Image/Video screen
          },
          child: Stack(
            children: [
              // Wrap the image in a Positioned.fill to fill the space
              Positioned.fill(
                child: Image.memory(bytes, fit: BoxFit.cover),
              ),
              // Display a Play icon if the asset is a video
              if (asset.type == AssetType.video)
                Center(
                  child: Container(
                    color: Colors.blue,
                    child: Icon(
                      Icons.play_arrow,
                      color: Colors.white,
                    ),
                  ),
                ),
            ],
          ),
        );
      },
    );
  }

我已经搜索了谷歌,但没有得到任何满意的答案。提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-03-06 09:05:26

试试这个解决方案:

代码语言:javascript
复制
FutureBuilder<Uint8List>

代码语言:javascript
复制
FutureBuilder<dynamic>

代码语言:javascript
复制
FutureBuilder<List<int>>
票数 1
EN

Stack Overflow用户

发布于 2021-03-06 09:11:15

只需省略该类型,编译器就足够聪明地将您提供的推断类型中的Future<>

代码语言:javascript
复制
FutureBuilder(
    future: asset.thumbData,
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66504012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档