Closed Adimarogonas closed 1 year ago
I figured out the solution
Future<File> getImageFileFromAssets(String path) async {
final byteData = await rootBundle.load('assets/$path');
DateTime now = DateTime.now();
final file = File(
'${(await getTemporaryDirectory()).path}/${now.toIso8601String()}');
await file.writeAsBytes(byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
return file;
}
did not write the png with a .png extension which
if (_backgroundResourcePath != null) {
var extension = _backgroundResourcePath.split(".").last;
print("EXTENSION: ${extension}, ${_backgroundResourcePath}");
if (["png", "jpg", "jpeg"].contains(extension.toLowerCase())) {
args["backgroundImage"] = _backgroundResourcePath;
print("Image");
} else {
args["backgroundVideo"] = _backgroundResourcePath;
print("video");
}
}
failed to mime it as an image. I would say this is user error on my part so I will close this issue. for other users that may be stuck in imageFileFromAssets use this and specify your extension(you can also set it to detect your extension):
Future<File> getImageFileFromAssets(String path) async {
final byteData = await rootBundle.load('assets/$path');
DateTime now = DateTime.now();
final file = File(
'${(await getTemporaryDirectory()).path}/${now.toIso8601String()}.png');
await file.writeAsBytes(byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
return file;
}
Thank you for adding video support and appID to this package.
Issues started for me after switching to 2.3.1 from before the appId. (using Flutter version 3.3.7) Problem: When I set the backgroundResourceImage before sharing the background image is not set. I checked with my implementation of getImageFileFromAssets() and the background image did show up when it was set as a sticker. I looked through the code itself as well as the iOS implementation and it seems to be fine so Im wondering if I'm doing something wrong. Code Sample:
Result:
Expected:
Flutter Doctor Output: