getResourceUrl method
Resolves a publication resource identified by its href to a loadable
URL.
The href should match a resource in the current publication's reading
order or resources manifest (e.g. an image link from ImageTapEvent.href).
On iOS/Android the resource is fetched natively and cached to an
app-owned file, returning a file:// URL; on Web it returns the
resource's served URL directly.
Web caveat: loading the returned URL as an image requires the
resource's server to send Access-Control-Allow-Origin — CanvasKit
always needs CORS to decode an image on Web, even just for display.
This is a browser/renderer constraint, not fixable client-side.
Throws PlatformException if the resource is not found or cannot be read. Implemented on iOS, Android, and Web.
Implementation
@override
Future<String> getResourceUrl(String href) async {
final result = await methodChannel.invokeMethod<String>(
'getResourceUrl',
{'href': href},
);
if (result == null) {
throw PlatformException(
code: 'ResourceNotFound',
message: 'getResourceUrl returned null for href: $href',
);
}
return result;
}