简体   繁体   English

我们可以提供 URL 而不是 flutter 中的 FlareActor 资产吗?

[英]Can we provide URL instead asset In FlareActor in flutter?

Is it possible to give firebase Url instead of asset in flareActor in flutter?是否可以在 flutter 中提供 firebase Url 而不是 flareActor 中的资产?

When you see something that takes a URL that points to data as a parameter, it must being doing a.network request at some point to obtain that data.当您看到将指向数据的 URL 作为参数时,它必须在某个时间点执行网络请求以获取该数据。 Since there is no URL constructor for a FlareActor , do your own .network request with the http package .由于 FlareActor 没有 URL 构造函数,请使用http FlareActor执行您自己的.network 请求。 Add the appropriate version to your pubspec.yaml dependencies.将适当的版本添加到您的 pubspec.yaml 依赖项中。

dependencies:
  http: ^0.12.2

Import the package into the file where you need the FlareActor .将 package 导入到您需要FlareActor的文件中。 Do a get request to obtain the data and pass the data to the FlareActor.memory constructor .做一个get请求获取数据并将数据传递给FlareActor.memory构造函数

var resp = await get(url);

FlareActor actor = FlareActor.memory(resp.bodyBytes);

Wrap the above code in a Future function and use a FutureBuilder in build to show your flare actor on the screen once it's ready.将以上代码包装在Future function 中,并在build中使用FutureBuilder准备就绪后在屏幕上显示您的耀斑演员。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们可以下载视频并在不将其添加到资产中的情况下使用 flutter 播放吗? - Can we download video and play it with flutter without add it into asset? 在Flutter小部件中显示时,FlareActor获取/设置.flr动画的持续时间 - FlareActor get/set duration of a .flr animation when showing in a Flutter widget Flutter:我们在哪里可以使用线性渐变而不是容器 - Flutter: where can we use linear gradient instead of container Flutter:如何优先显示来自 Asset 的图像,如果找不到,则显示来自 URL 的图像? - Flutter: How to prioritize displaying the image from Asset, if it can't be found, then display image from URL? 我们如何从 flutter 的底部导航栏启动 url - How can we launch the url from the bottom naviagtion bar in flutter 如果 flutter 中的 url 是 null,如何提供备用图像? - How to provide alternate image if url is null in flutter? 无法在颤动中显示资产中的图像 - Can't show image from asset in flutter 是我们可以使用 GridView.builder 为颤振中的网格项提供特定高度(纵横比提供错误)的任何方式 - is their any way we can provide specific height (aspect ratio provides error)to grid item in flutter using GridView.builder 我们可以在服务器上离线运行 Flutter 项目而不是使用 Internet 连接吗? - Can We Run The Flutter Project offline on server instead of using The Internet connection? 如何从 url 下载文件并将文件保存在 flutter 的资产文件夹中? - How to download a file from url and save the file in asset folder in flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM