Right now a FlareActor can be initialized only with a path of a file from the rootBundle.
I think it would be really useful to support a few other loading modes (e.g. network, string, bytes, ...)
I saw that the FlutterActor is the thing that actually is being loaded async. one possibile approach is to have a constructor with the following signature
FlareActor.asyncBytes(Future<Uint8List> Function() loadBytes, {void Function() onCancel});
The onCancel function would be useful in order to abort a potentially long running loading operation (for example from the network) if the render object has been disposed in the meantime.
This is dead on. We definitely want to support more loading paths, we just haven't made a nice API for them yet. The network load is a big one for us as loading directly from your source file on 2Dimensions.com is a feature we plan to support soon.
feature we plan t
Any updates on this feature?
Try this:
class FileFlare extends AssetProvider {
final String name;
FileFlare(this.name);
@override
Future<ByteData> load() async {
final cacheDir = await getTemporaryDirectory();
final file = File('${cacheDir.path}/$name');
final bytes = file.readAsBytesSync();
return ByteData.view(bytes.buffer);
}
}
Usage:
FlareActor.asset(FileFlare('hello.flr'));
Most helpful comment
Try this:
Usage: