getObject method Null safety

SynthizerObject getObject(
  1. int handle
)

Get an object from handle.

NOTE: Objects constructed by this method should be used for comparison only.

If you try to access properties for example, the behaviour is undefined.

Implementation

SynthizerObject getObject(int handle) {
  final type = getObjectType(handle);
  switch (type) {
    case ObjectType.context:
      return Context(this, pointer: handle);
    case ObjectType.buffer:
      return Buffer(this, handle: handle);
    case ObjectType.bufferGenerator:
      return BufferGenerator.fromHandle(this, handle);
    case ObjectType.streamingGenerator:
      return StreamingGenerator.fromHandle(this, handle);
    case ObjectType.noiseGenerator:
      return NoiseGenerator.fromHandle(this, handle);
    case ObjectType.directSource:
      return DirectSource.fromHandle(this, handle);
    case ObjectType.angularPannedSource:
      return AngularPannedSource.fromHandle(this, handle);
    case ObjectType.scalarPannedSource:
      return ScalarPannedSource.fromHandle(this, handle);
    case ObjectType.source3d:
      return Source3D.fromHandle(this, handle);
    case ObjectType.globalEcho:
      return GlobalEcho.fromHandle(this, handle);
    case ObjectType.globalFdnReverb:
      return GlobalFdnReverb.fromHandle(this, handle);
    case ObjectType.streamHandle:
      throw UnimplementedError();
    case ObjectType.automationBatch:
      return AutomationBatch.fromHandle(this, handle);
    case ObjectType.fastSineBankGenerator:
      return FastSineBankGenerator.fromHandle(this, handle);
  }
}