Skip to content

Inability to use ui.Canvas.drawPoints(...) in Flutter for the web. #49580

@domesticmouse

Description

@domesticmouse

I believe I am post flutter/engine#15870 but I have included the output from flutter doctor below to confirm one way or the other.

I am attempting to use ui.Canvas.drawPoints(...) in Flutter for the web, but tripping over Unimplemented errors.

════════ Exception caught by rendering library ═════════════════════════════════
The following UnimplementedError was thrown during paint():
UnimplementedError

When the exception was thrown, this was the stack
throw_ (package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart:196:49)
drawPoints (package:build_web_compilers/lib/ui/src/ui/canvas.dart:953:5)
draw
package:vector_paint/main.dart:75
<fn>
package:vector_paint/main.dart:130
forEach] (package:dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart:205:8)
...
The following RenderObject was being processed when the exception was fired: RenderCustomPaint#42a4c relayoutBoundary=up7
RenderObject: RenderCustomPaint#42a4c relayoutBoundary=up7
    parentData: <none> (can use size)
    constraints: BoxConstraints(0.0<=w<=840.0, 0.0<=h<=892.0)
    size: Size(840.0, 892.0)
════════════════════════════════════════════════════════════════════════════════

My code looks like the following:

    final paint = Paint()
      ..color = _color
      ..strokeWidth = _radius
      ..style = PaintingStyle.stroke
      ..strokeCap = StrokeCap.round;
    canvas.drawPoints(
        _points.length > 1 ? ui.PointMode.polygon : ui.PointMode.points,
        _points,
        paint);

Where _points is a List<ui.Offset>.

Flutter doctor output:

flutter doctor -v                
[✓] Flutter (Channel master, v1.14.3-pre.2, on Mac OS X 10.15.2 19C57, locale en)
    • Flutter version 1.14.3-pre.2 at /Users/brettmorgan/flutter
    • Framework revision ac7b307803 (7 days ago), 2020-01-20 23:23:02 -0800
    • Engine revision aa50eae0f7
    • Dart version 2.8.0 (build 2.8.0-dev.3.0 f96c48307d)

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.


[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2019.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 42.2.2
    • Dart plugin version 192.7761

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • macOS      • macOS      • darwin-x64     • Mac OS X 10.15.2 19C57
    • Chrome     • chrome     • web-javascript • Google Chrome 79.0.3945.130
    • Web Server • web-server • web-javascript • Flutter Tools

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

platform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions