Path.create constructor

Path.create({
  1. required Uint8List data,
  2. PathFileFormat format = PathFileFormat.gpx,
})

Creates a Path by importing binary data in a supported format.

The data bytes contain the file contents (for example a GPX or KML file). The format controls how the bytes are interpreted. The returned Path instance is backed by the native SDK representation.

Parameters

Returns

  • A new Path instance created from the provided data.

Implementation

factory Path.create({
  required final Uint8List data,
  final PathFileFormat format = PathFileFormat.gpx,
}) {
  final dynamic nativeBuffer = GemKitPlatform.instance.toNativePointer(data);
  final dynamic resultString = GemKitPlatform.instance.callCreateObject(
    jsonEncode(<String, Object>{
      'class': 'Path',
      'args': <String, dynamic>{
        'data': nativeBuffer.address,
        'dataLength': data.length,
        'format': format.id,
      },
    }),
  );
  GemKitPlatform.instance.freeNativePointer(nativeBuffer);
  final dynamic decodedVal = jsonDecode(resultString);

  return Path.init(decodedVal['result']);
}