[英]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.