Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Ignore implicit_dynamic_function analyzer error for js_util generic methods #29192

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class CanvasPool extends _SaveStackTracking {

html.CanvasElement? _allocCanvas(int width, int height) {
final dynamic canvas =
// ignore: implicit_dynamic_function
js_util.callMethod(html.document, 'createElement', <dynamic>['CANVAS']);
if (canvas != null) {
try {
Expand Down
6 changes: 6 additions & 0 deletions lib/web_ui/lib/src/engine/dom_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ class DomRenderer {
/// See for more details:
/// https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus
bool get windowHasFocus =>
// ignore: implicit_dynamic_function
js_util.callMethod(html.document, 'hasFocus', <dynamic>[]) as bool;

void _setupHotRestart() {
// This persists across hot restarts to clear stale DOM.
_staleHotRestartState =
// ignore: implicit_dynamic_function
js_util.getProperty(html.window, _staleHotRestartStore) as List<html.Element?>?;
if (_staleHotRestartState == null) {
_staleHotRestartState = <html.Element?>[];
Expand Down Expand Up @@ -232,6 +234,7 @@ class DomRenderer {

static void setElementTransform(html.Element element, String transformValue) {
js_util.setProperty(
// ignore: implicit_dynamic_function
js_util.getProperty(element, 'style') as Object,
'transform',
transformValue,
Expand Down Expand Up @@ -453,6 +456,7 @@ class DomRenderer {

// Creates a [HostNode] into a `root` [html.Element].
HostNode _createHostNode(html.Element root) {
// ignore: implicit_dynamic_function
if (js_util.getProperty(root, 'attachShadow') != null) {
return ShadowDomHostNode(root);
} else {
Expand Down Expand Up @@ -523,6 +527,7 @@ class DomRenderer {
double startAngle,
double endAngle,
bool antiClockwise) {
// ignore: implicit_dynamic_function
_ellipseFeatureDetected ??= js_util.getProperty(context, 'ellipse') != null;
if (_ellipseFeatureDetected!) {
context.ellipse(centerX, centerY, radiusX, radiusY, rotation, startAngle,
Expand Down Expand Up @@ -649,6 +654,7 @@ class DomRenderer {
void vibrate(int durationMs) {
final html.Navigator navigator = html.window.navigator;
if (js_util.hasProperty(navigator, 'vibrate')) {
// ignore: implicit_dynamic_function
js_util.callMethod(navigator, 'vibrate', <num>[durationMs]);
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/web_ui/lib/src/engine/html/offscreen_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class OffScreenCanvas {
void transferImage(Object targetContext) {
// Actual size of canvas may be larger than viewport size. Use
// source/destination to draw part of the image data.
// ignore: implicit_dynamic_function
js_util.callMethod(targetContext, 'drawImage',
<dynamic>[offScreenCanvas ?? canvasElement!, 0, 0, width, height,
0, 0, width, height]);
Expand All @@ -77,6 +78,7 @@ class OffScreenCanvas {
final html.FileReader fileReader = html.FileReader();
fileReader.onLoad.listen((html.ProgressEvent event) {
completer.complete(
// ignore: implicit_dynamic_function
js_util.getProperty(js_util.getProperty(event, 'target') as Object, 'result') as String,
);
});
Expand All @@ -90,6 +92,7 @@ class OffScreenCanvas {

/// Draws an image to canvas for both offscreen canvas canvas context2d.
void drawImage(Object image, int x, int y, int width, int height) {
// ignore: implicit_dynamic_function
js_util.callMethod(
getContext2d()!, 'drawImage', <dynamic>[image, x, y, width, height]);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/web_ui/lib/src/engine/html/path/path_ref.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ class PathRef {
resetToSize(verbCount, pointCount, weightCount, additionalReserveVerbs,
additionalReservePoints);

// ignore: implicit_dynamic_function
js_util.callMethod(_fVerbs, 'set', <dynamic>[ref._fVerbs]);
// ignore: implicit_dynamic_function
js_util.callMethod(fPoints, 'set', <dynamic>[ref.fPoints]);
if (ref._conicWeights == null) {
_conicWeights = null;
Expand All @@ -456,6 +458,7 @@ class PathRef {
if (newLength > _fPointsCapacity) {
_fPointsCapacity = newLength + 10;
final Float32List newPoints = Float32List(_fPointsCapacity * 2);
// ignore: implicit_dynamic_function
js_util.callMethod(newPoints, 'set', <dynamic>[fPoints]);
fPoints = newPoints;
}
Expand All @@ -466,6 +469,7 @@ class PathRef {
if (newLength > _fVerbsCapacity) {
_fVerbsCapacity = newLength + 8;
final Uint8List newVerbs = Uint8List(_fVerbsCapacity);
// ignore: implicit_dynamic_function
js_util.callMethod(newVerbs, 'set', <dynamic>[_fVerbs]);
_fVerbs = newVerbs;
}
Expand All @@ -477,6 +481,7 @@ class PathRef {
_conicWeightsCapacity = newLength + 4;
final Float32List newWeights = Float32List(_conicWeightsCapacity);
if (_conicWeights != null) {
// ignore: implicit_dynamic_function
js_util.callMethod(newWeights, 'set', <dynamic>[_conicWeights]);
}
_conicWeights = newWeights;
Expand Down
4 changes: 4 additions & 0 deletions lib/web_ui/lib/src/engine/html/render_vertices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class _WebGlRenderer implements GlRenderer {
bufferVertexData(gl, positions, 1.0);

// Setup data format for attribute.
// ignore: implicit_dynamic_function
js_util.callMethod(gl.glContext, 'vertexAttribPointer', <dynamic>[
positionAttributeLocation,
2,
Expand Down Expand Up @@ -233,6 +234,7 @@ class _WebGlRenderer implements GlRenderer {
gl.bufferData(vertices.colors, gl.kStaticDraw);
}
final Object colorLoc = gl.getAttributeLocation(glProgram.program, 'color');
// ignore: implicit_dynamic_function
js_util.callMethod(gl.glContext, 'vertexAttribPointer',
<dynamic>[colorLoc, 4, gl.kUnsignedByte, true, 0, 0]);
gl.enableVertexAttribArray(colorLoc);
Expand Down Expand Up @@ -374,6 +376,7 @@ class _WebGlRenderer implements GlRenderer {
gl.bindArrayBuffer(positionsBuffer);
gl.bufferData(vertices, gl.kStaticDraw);
// Point an attribute to the currently bound vertex buffer object.
// ignore: implicit_dynamic_function
js_util.callMethod(gl.glContext, 'vertexAttribPointer',
<dynamic>[0, 2, gl.kFloat, false, 0, 0]);
gl.enableVertexAttribArray(0);
Expand All @@ -389,6 +392,7 @@ class _WebGlRenderer implements GlRenderer {
0xFF00FFFF,
]);
gl.bufferData(colors, gl.kStaticDraw);
// ignore: implicit_dynamic_function
js_util.callMethod(gl.glContext, 'vertexAttribPointer',
<dynamic>[1, 4, gl.kUnsignedByte, true, 0, 0]);
gl.enableVertexAttribArray(1);
Expand Down
4 changes: 4 additions & 0 deletions lib/web_ui/lib/src/engine/html/shaders/image_shader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ class EngineImageShader implements ui.ImageShader {
/// To draw image flipped we set translate and scale and pass
/// negative width/height to drawImage.
if (flipX != 1 || flipY != 1) {
// ignore: implicit_dynamic_function
js_util.callMethod(renderContext, 'scale', <dynamic>[flipX, flipY]);
}
// ignore: implicit_dynamic_function
js_util.callMethod(renderContext, 'drawImage', <dynamic>[
image.imgElement,
if (x == 0) 0 else -2 * imageWidth,
if (y == 0) 0 else -2 * imageHeight,
]);
if (flipX != 1 || flipY != 1) {
/// Restore transform. This is faster than save/restore on context.
// ignore: implicit_dynamic_function
js_util.callMethod(renderContext, 'scale', <dynamic>[flipX, flipY]);
}
}
Expand Down Expand Up @@ -205,6 +208,7 @@ class EngineImageShader implements ui.ImageShader {
bufferVertexData(gl, vertices, ui.window.devicePixelRatio);

/// Setup data format for attribute.
// ignore: implicit_dynamic_function
js_util.callMethod(gl.glContext, 'vertexAttribPointer', <dynamic>[
positionAttributeLocation,
2,
Expand Down
Loading