ModelViewerProController class

Controller for a ModelViewerProViewer widget.

Create a single instance and pass it to the controller parameter of ModelViewerProViewer. Once the viewer calls setWebViewController (done automatically by the widget), all methods become active.

All feature methods are provided by mixed-in operation classes:

Example

final controller = ModelViewerProController();

ModelViewerProViewer(
  src: 'assets/model.glb',
  controller: controller,
  onLoad: (meshes) async {
    await controller.setShadowIntensity(0.8);
  },
)
Mixed-in types

Constructors

ModelViewerProController()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
webViewController → WebViewController?
Required by each mixin so it can access the underlying WebViewController.
no setteroverride

Methods

dispose() → void
Detaches the controller from the WebView and releases resources.
executeCustomJS(String script) Future<void>
Runs arbitrary JavaScript against the page hosting the model-viewer.
getAnimationDuration() Future<double?>
Returns the total duration of the currently active animation in seconds.
inherited
getAvailableMeshes() Future<List<String>>
Returns all named mesh nodes found in the currently loaded model.
inherited
getAvailableMeshesWithState() Future<List<Map<String, dynamic>>>
Returns all named mesh nodes with their current visibility state.
inherited
getCameraOrbit() Future<Map<String, dynamic>?>
Returns the current camera orbit as a map with keys theta, phi, and radius (all in SI units from model-viewer: radians / metres).
inherited
loadEnvironmentFromAsset(String assetPath) Future<bool>
Loads an environment / reflection image from assetPath.
inherited
loadSkyboxFromAsset(String assetPath) Future<bool>
Loads a skybox image from assetPath and applies it to model-viewer.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pauseAnimation() Future<void>
Pauses the currently playing animation at its current position.
inherited
playAnimation() Future<void>
Starts playing the model's animation(s).
inherited
removeSkyboxHeight() Future<bool>
Removes skybox-height so the skybox displays as a full 360° sphere.
resetCamera() Future<void>
Resets the camera to its default position and clears any turntable offset.
inherited
runJsSafe(String script) Future<Object>
Safely executes JavaScript, ensuring the ModelViewerProManager is injected if the WebView reloaded or cleared its context.
override
runJsSafeVoid(String script) Future<void>
Safely executes JavaScript without returning a result.
override
setAnimationTime(double timeInSeconds) Future<void>
Seeks to timeInSeconds in the animation timeline.
inherited
setAutoRotate(bool enabled) Future<void>
Enables or disables continuous auto-rotation of the model.
inherited
setBackgroundColor(String color) Future<bool>
Sets the CSS background colour of the viewer element.
inherited
setCameraOrbit(double theta, double phi, double radius) Future<void>
Moves the camera to the specified orbit position.
inherited
setCameraTarget(double x, double y, double z) Future<void>
Sets the point in the scene that the camera looks at.
inherited
setDisablePan(bool disabled) Future<bool>
Enables or disables panning (two-finger drag on touch / middle-mouse).
setDisableTap(bool disabled) Future<bool>
Enables or disables tapping on the model.
setDisableZoom(bool disabled) Future<bool>
Enables or disables zooming (pinch on touch / scroll wheel).
setEnvironmentImage(String url) Future<bool>
Deprecated — use setEnvironmentImageFromUrl or setEnvironmentImageFromAsset instead.
inherited
setEnvironmentImageFromAsset(String assetPath) Future<bool>
Sets the environment image used for reflections from a Flutter asset path.
inherited
setEnvironmentImageFromUrl(String url) Future<bool>
Sets the environment image used for reflections from a remote url.
inherited
setExclusiveMesh(List<String> group, String activeMeshName) Future<void>
Ensures that within the provided group of mesh names, only the activeMeshName is visible, and all other meshes in the group are hidden.
inherited
setExposure(double value) Future<bool>
Sets the scene exposure / brightness multiplier.
inherited
setFieldOfView(double fov) Future<void>
Sets the camera field of view in degrees.
inherited
setGroundVisibility(bool visible) Future<bool>
Shows or hides the ground shadow beneath the model.
inherited
setMaxCameraOrbit(String orbit) Future<bool>
Sets the max-camera-orbit attribute to restrict how far the user can orbit the camera.
setMinCameraOrbit(String orbit) Future<bool>
Sets the min-camera-orbit attribute.
setShadowIntensity(double value) Future<bool>
Sets the shadow intensity (darkness).
inherited
setShadowSoftness(double value) Future<bool>
Sets the shadow blur / softness.
inherited
setSkyboxHeight(String height) Future<bool>
Sets the skybox-height attribute on model-viewer.
setSkyboxImage(String url) Future<bool>
Deprecated — use setSkyboxImageFromUrl or setSkyboxImageFromAsset instead.
inherited
setSkyboxImageFromAsset(String assetPath) Future<bool>
Sets the 360° skybox background image from a Flutter asset path.
inherited
setSkyboxImageFromUrl(String url) Future<bool>
Sets the 360° skybox background image from a remote url.
inherited
setTextureColor(String meshName, String colorHex) Future<void>
Changes the base colour of the mesh named meshName.
inherited
setTouchAction(String action) Future<bool>
Sets the CSS touch-action on the model-viewer element.
setVisibility(String meshName, bool isVisible) Future<void>
Shows or hides the node named meshName and all its children.
inherited
setWebViewController(WebViewController controller) → void
Called automatically by ModelViewerProViewer when the WebView is ready.
takeScreenshot() Future<String?>
Captures the current rendered frame as a PNG data URL.
toString() String
A string representation of this object.
inherited
waitForSceneReady({int timeoutMs = 3000}) Future<bool>
Waits until the model-viewer scene graph is accessible.
zoomIn() Future<void>
Zooms in by reducing the orbit radius by 20%.
inherited
zoomOut() Future<void>
Zooms out by increasing the orbit radius by 20%.
inherited

Operators

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