project method Null safety

Future<MercatorCoordinate> project(
  1. Map<String?, Object?> arg_coordinate,
  2. double arg_zoomScale
)

Calculate a point on the map in Mercator Projection for a given coordinate at the specified zoom scale.

@param coordinate The longitude-latitude pair for which to return the value. @param zoomScale The current zoom factor (2 ^ Zoom level) applied on the map, is used to calculate the world size as tileSize * zoomScale (i.e., 512 * 2 ^ Zoom level) where tileSize is the width of a tile in pixels.

@return Returns a point on the map in Mercator projection.

Implementation

Future<MercatorCoordinate> project(
    Map<String?, Object?> arg_coordinate, double arg_zoomScale) async {
  final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.mapbox_maps_flutter.Projection.project', codec,
      binaryMessenger: _binaryMessenger);
  final List<Object?>? replyList = await channel
      .send(<Object?>[arg_coordinate, arg_zoomScale]) as List<Object?>?;
  if (replyList == null) {
    throw PlatformException(
      code: 'channel-error',
      message: 'Unable to establish connection on channel.',
    );
  } else if (replyList.length > 1) {
    throw PlatformException(
      code: replyList[0]! as String,
      message: replyList[1] as String?,
      details: replyList[2],
    );
  } else if (replyList[0] == null) {
    throw PlatformException(
      code: 'null-error',
      message: 'Host platform returned null value for non-null return value.',
    );
  } else {
    return (replyList[0] as MercatorCoordinate?)!;
  }
}