currentAdapter property

  1. @Deprecated('The process-global adapter slot is deprecated. Register a controller type ' 'with Nutrient.addAdapterClass<T>() and select it via ' 'NutrientDocumentView<T>; access the controller through that view\'s ' 'onControllerReady. Will be removed in a future release.')
NutrientPlatformAdapter? get currentAdapter

Get the current platform adapter.

Returns the adapter for the current platform:

Returns null if:

  • SDK not initialized
  • No adapter registered for current platform

Example:

final adapter = Nutrient.currentAdapter;
if (adapter != null) {
  adapter.events.listen((event) {
    print('Event: $event');
  });
}

Implementation

@Deprecated(
  'The process-global adapter slot is deprecated. Register a controller type '
  'with Nutrient.addAdapterClass<T>() and select it via '
  'NutrientDocumentView<T>; access the controller through that view\'s '
  'onControllerReady. Will be removed in a future release.',
)
static NutrientPlatformAdapter? get currentAdapter {
  if (!_initialized) return null;

  switch (defaultTargetPlatform) {
    case TargetPlatform.android:
      return _androidAdapter;
    case TargetPlatform.iOS:
      return _iosAdapter;
    case TargetPlatform.linux:
    case TargetPlatform.macOS:
    case TargetPlatform.windows:
    case TargetPlatform.fuchsia:
      // Web is handled by kIsWeb check
      return _webAdapter;
  }
}