toCommand method
Implementation
Future<String> toCommand() async {
if (_path.isNotEmpty) {
try {
if (_source != WatermarkSourceEnum.file) {
ByteData byteData;
String appDocDir;
File file;
byteData = _source == WatermarkSourceEnum.asset
? await rootBundle.load(_path)
: await NetworkAssetBundle(Uri.parse(_path)).load("");
appDocDir = await getApplicationDocumentsDirectory()
.then((value) => value.path);
file = await File('$appDocDir/$_path').create(recursive: true);
_path = await file
.writeAsBytes(byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes))
.then((value) => value.path);
}
} catch (e) {
throw ("Unable to fetch image from the mentioned source.");
}
return _path;
} else {
throw ("Add Image source using WatermarkSource");
}
}