overwriteNodeValidatorBuilder property
Customize allowed tags & attrubutes for Web platform.
Solution of console output Removing disallowed attribute ...
.
In model-viewer Change Color Example, we can see codes like:
<model-viewer id="color" camera-controls touch-action="pan-y" interaction-prompt="none" src="../../shared-assets/models/Astronaut.glb" ar alt="A 3D model of an astronaut">
<div class="controls" id="color-controls">
<button data-color="#ff0000">Red</button>
<!-- ... some codes ... -->
</div>
</model-viewer>
If overwriteNodeValidatorBuilder is not specified, you may see
Removing disallowed attribute <BUTTON data-color="#0000ff">
in the console.
To make them work on Flutter Web, you need to copy our
defaultNodeValidatorBuilder and specify overwriteNodeValidatorBuilder
for your need. You may do something like:
import 'package:model_viewer_plus/src/model_viewer_plus_web.dart';
import 'package:model_viewer_plus/src/shim/dart_html_fake.dart'
if (dart.library.html) 'dart:html';
NodeValidatorBuilder myNodeValidatorBuilder = defaultNodeValidatorBuilder
..allowElement('button',
attributes: ['data-color'], uriPolicy: AllowAllUri());
ModelViewer(overwriteNodeValidatorBuilder: myNodeValidatorBuilder,);
See also: NodeValidatorBuilder
Implementation
final NodeValidatorBuilder? overwriteNodeValidatorBuilder;