ServiceGeodatabase.withPortalItem constructor

ServiceGeodatabase.withPortalItem(
  1. PortalItem portalItem, {
  2. String versionName = '',
  3. FeatureServiceSessionType sessionType = FeatureServiceSessionType.transient,
})

Creates a new ServiceGeodatabase from a feature service portal item, and connects to a specific version in the feature service.

If a version with the name does not exist, or the service is not branch versioned, the ServiceGeodatabase will fail to load.

If using FeatureServiceSessionType.persistent and the service is not branch versioned, the ServiceGeodatabase will fail to load.

If using FeatureServiceSessionType.persistent, it is important to call ServiceGeodatabase.close before destruction.

Parameters:

  • portalItem — A feature service PortalItem.
  • versionName — The existing version to connect to when the ServiceGeodatabase loads.
  • sessionType — The type of read and edit sessions to use when working with the service.

Implementation

factory ServiceGeodatabase.withPortalItem(
  PortalItem portalItem, {
  String versionName = '',
  FeatureServiceSessionType sessionType = FeatureServiceSessionType.transient,
}) {
  _initializeArcGISEnvironmentIfNeeded();
  final coreVersionName = _CString(versionName);
  final handle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_ServiceGeodatabase_createWithPortalItemCombined(
      portalItem._handle,
      coreVersionName.bytes,
      sessionType.coreValue,
      errorHandler,
    );
  });
  return ServiceGeodatabase._instanceCache.instanceWith(handle);
}