VapController class

Controller for programmatic management of VAP animations.

VapController provides methods to:

  • Control playback (play, stop, loop settings)
  • Manage dynamic content (set, get, clear VAP tag contents)
  • Listen to animation events (start, complete, error, etc.)
  • Configure playback settings (mute, scale type)

The controller is obtained through VapView.onViewCreated callback and should be disposed when no longer needed to prevent memory leaks.

Example usage:

VapController controller;

// Set event listeners
controller.setAnimListener(
  onVideoStart: () => print('Started'),
  onVideoComplete: () => print('Completed'),
  onFailed: (code, type, msg) => print('Error: $code'),
);

// Play animation
await controller.playAsset('animations/sample.mp4');

// Set dynamic content
await controller.setVapTagContent('username', TextContent('John'));

// Clean up
controller.dispose();

Constructors

VapController()

Properties

hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Checks if the controller has been disposed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearVapTagContents() Future<void>
Clears all VAP tag contents.
dispose() Future<void>
Disposes the controller and releases associated resources.
getAllVapTagContents() Future<Map<String, VAPContent>>
Gets all currently set VAP tag contents.
getVapTagContent(String tag) Future<VAPContent?>
Gets the content for a specific VAP tag.
hasVapTagContent(String tag) Future<bool>
Checks if a specific VAP tag has content set.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
playAsset(String assetName) Future<void>
Plays a VAP animation from a Flutter asset.
playFile(String filePath) Future<void>
Plays a VAP animation from a file path.
removeVapTagContent(String tag) Future<void>
Removes content for a specific VAP tag.
setAnimListener({OnFailed? onFailed, OnVideoComplete? onVideoComplete, OnVideoDestroy? onVideoDestroy, OnVideoRender? onVideoRender, OnVideoStart? onVideoStart, OnVideoConfigReady? onVideoConfigReady}) → void
Sets event listeners for various animation events.
setLoop(int loop) Future<void>
Sets the loop count for animation playback.
setMute(bool mute) Future<void>
Sets the mute state for animation playback.
setScaleType(String scaleType) Future<void>
Sets the scale type for animation display.
setVapTagContent(String tag, VAPContent content) Future<void>
Sets content for a specific VAP tag.
setVapTagContents(Map<String, VAPContent> contents) Future<void>
Sets multiple VAP tag contents at once.
stop() Future<void>
Stops the current animation playback.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited