flutterToNativeModule static method
Implementation
static Future<bool?> flutterToNativeModule(
FCPChannelTypes type, [
dynamic data,
bool Function()? isCurrent,
]) async {
// Rasterize any Flutter asset SVGs referenced by image fields into PNG
// bytes before sending the payload to the native side, which cannot render
// SVG directly. Non-collection payloads pass through unchanged.
await resolveSvgInPayload(data, size: FlutterCarplay.svgRasterSize);
if (data is Map) data = Map<dynamic, dynamic>.from(data);
applyDefaultImageSize(data, FlutterCarplay.iconSize);
if (data is Map &&
data.keys.any(
(key) =>
key == 'rootTemplate' ||
key == 'template' ||
key == 'sections' ||
key == 'elements' ||
key == 'searchResults' ||
autoImageSizeKeys.containsKey(key) ||
autoImageSizeListKeys.containsKey(key),
)) {
data['debugImageSizing'] = FlutterCarplay.debugImageSizing;
}
if (isCurrent != null && !isCurrent()) return false;
final value = await _methodChannel.invokeMethod<bool>(type.name, data);
return value;
}