getNextPlatformViewId method

int getNextPlatformViewId()

Allocates a unique identifier for a platform view.

A platform view identifier can refer to a platform view that was never created, a platform view that was disposed, or a platform view that is alive.

Typically a platform view identifier is passed to a platform view widget which creates the platform view and manages its lifecycle.

Implementation

int getNextPlatformViewId() {
  // On the Android side, the interface exposed to users uses 32-bit integers.
  // See https://github.com/flutter/engine/pull/39476 for more details.

  // We can safely assume that a Flutter application will not require more
  // than MAX_INT32 platform views during its lifetime.
  const int MAX_INT32 = 0x7FFFFFFF;
  assert(_nextPlatformViewId <= MAX_INT32);
  return _nextPlatformViewId++;
}