setFromAsset method
Implementation
Future<void> setFromAsset({
required final String path,
final int? maxSize
}) async {
if (path.isEmpty) throw Exception("path cant be empty");
if (_urlPattern.hasMatch(path)) throw Exception("A URL can't be an asset");
await rootBundle.load(path)
.then((data) async {
final extension = path.split('.').last.split('?').first;
await PlatformTools().write(
name : '${DateTime.now().millisecondsSinceEpoch}${Random().nextInt(10000)}-${path.split('/').last.split('.').first}',
extension : extension,
bytes : data.buffer.asUint8List(),
maxSize : maxSize
).then((_f) {
_file = _f;
_bytes = _f.bytes;
_error = false;
_hasImage = true;
_extension = extension;
notifyListeners();
}).onError((error, stackTrace) => _reset(error: true));
})
.onError((error, stackTrace) => _reset(error: true));
}