Repository: flutter
Issue: Make Canvas a sealed class
Labels: c: new feature,engine,platform-web,has reproducible steps,P3,found in release: 3.3,found in release: 3.7,team-web,triaged-web

## Steps to Reproduce

In a new project, paste the code below. It creates a subclass of Canvas and tries to instantiate it.

**Expected results:**
This compiles and runs with no error on all platforms.

**Actual results:**
It fails to compile for Web, but compiles and runs in other platforms.

<details>
<summary>Code sample</summary>

```dart
import 'dart:ui';

import 'package:flutter/material.dart';

void main() {
  final c = MyCanvas(PictureRecorder());
  print(c);
  runApp(const MyApp());
}

class MyCanvas extends Canvas {
  MyCanvas(super.recorder);
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Demo'),
        ),
        body: const Center(
          child: Text('It works'),
        ),
      ),
    );
  }
}
```
</details>

<details>
  <summary>Logs</summary>

```
% flutter run -d chrome --verbose
[   +7 ms] executing: sysctl hw.optional.arm64
[   +5 ms] Exit code 0 from: sysctl hw.optional.arm64
[        ] hw.optional.arm64: 1
[        ] executing: [/Users/anhtuan/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +8 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
[        ] executing: [/Users/anhtuan/flutter/] git tag --points-at e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
[  +18 ms] Exit code 0 from: git tag --points-at e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
[        ] 3.7.0-1.1.pre
[   +7 ms] executing: [/Users/anhtuan/flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
[   +8 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
[        ] origin/beta
[        ] executing: [/Users/anhtuan/flutter/] git ls-remote --get-url origin
[  +10 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +15 ms] executing: [/Users/anhtuan/flutter/] git rev-parse --abbrev-ref HEAD
[  +10 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[        ] executing: sw_vers -productName
[   +9 ms] Exit code 0 from: sw_vers -productName
[        ] macOS
[        ] executing: sw_vers -productVersion
[  +10 ms] Exit code 0 from: sw_vers -productVersion
[        ] 13.0.1
[        ] executing: sw_vers -buildVersion
[   +8 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 22A400
[        ] executing: uname -m
[   +5 ms] Exit code 0 from: uname -m
[        ] arm64
[  +15 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +26 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +20 ms] executing: sysctl hw.optional.arm64
[   +3 ms] Exit code 0 from: sysctl hw.optional.arm64
[        ] hw.optional.arm64: 1
[        ] executing: /usr/bin/arch -arm64e xcrun xcodebuild -version
[  +99 ms] Exit code 0 from: /usr/bin/arch -arm64e xcrun xcodebuild -version
[        ] Xcode 14.1
           Build version 14B47b
[  +26 ms] Skipping pub get: version match.
[  +73 ms] Generating /Users/anhtuan/git/web_canvas/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +76 ms] Launching lib/main.dart on Chrome in debug mode...
[  +48 ms] Initializing file store
[   +4 ms] Skipping target: gen_localizations
[   +2 ms] Skipping target: gen_dart_plugin_registrant
[        ] Skipping target: _composite
[        ] complete
[        ] Updating assets
[  +44 ms] Waiting for connection from debug service on Chrome...
[  +24 ms] <- reset
[   +3 ms] /Users/anhtuan/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /Users/anhtuan/flutter/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot
--sdk-root /Users/anhtuan/flutter/bin/cache/flutter_web_sdk/ --incremental --target=dartdevc --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill
/var/folders/ym/2b7pw1yn0v71ybqwb07t4vw00000gn/T/flutter_tools.15w4lL/flutter_tool.lEGgu5/app.dill --packages /Users/anhtuan/git/web_canvas/.dart_tool/package_config.json
-Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root
/var/folders/ym/2b7pw1yn0v71ybqwb07t4vw00000gn/T/flutter_tools.15w4lL/flutter_tools.7jhEsq --filesystem-scheme org-dartlang-app --initialize-from-dill
build/b1b715402d823b7fd5c2b68d2edcb2ce.cache.dill.track.dill --platform file:///Users/anhtuan/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill
--verbosity=error --sound-null-safety
[  +15 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[ +869 ms] lib/main.dart:11:7: Error: The non-abstract class 'MyCanvas' is missing implementations for these members:
[        ]  - Canvas.clipPath
[        ]  - Canvas.clipRRect
[        ]  - Canvas.clipRect
[        ]  - Canvas.drawArc
[        ]  - Canvas.drawAtlas
[        ]  - Canvas.drawCircle
[        ]  - Canvas.drawColor
[        ]  - Canvas.drawDRRect
[        ]  - Canvas.drawImage
[        ]  - Canvas.drawImageNine
[        ]  - Canvas.drawImageRect
[        ]  - Canvas.drawLine
[        ]  - Canvas.drawOval
[        ]  - Canvas.drawPaint
[        ]  - Canvas.drawParagraph
[        ]  - Canvas.drawPath
[        ]  - Canvas.drawPicture
[        ]  - Canvas.drawPoints
[        ]  - Canvas.drawRRect
[        ]  - Canvas.drawRawAtlas
[        ]  - Canvas.drawRawPoints
[        ]  - Canvas.drawRect
[        ]  - Canvas.drawShadow
[        ]  - Canvas.drawVertices
[        ]  - Canvas.getDestinationClipBounds
[        ]  - Canvas.getLocalClipBounds
[        ]  - Canvas.getSaveCount
[        ]  - Canvas.getTransform
[        ]  - Canvas.restore
[        ]  - Canvas.restoreToCount
[        ]  - Canvas.rotate
[        ]  - Canvas.save
[        ]  - Canvas.saveLayer
[        ]  - Canvas.scale
[        ]  - Canvas.skew
[        ]  - Canvas.transform
[        ]  - Canvas.translate
[        ] Try to either
[        ]  - provide an implementation,
[        ]  - inherit an implementation from a superclass or mixin,
[        ]  - mark the class as abstract, or
[        ]  - provide a 'noSuchMethod' implementation.
[        ] class MyCanvas extends Canvas {
[        ]       ^^^^^^^^
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.clipPath' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.clipRRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.clipRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawArc' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawAtlas' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawCircle' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawColor' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawDRRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawImage' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawImageNine' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawImageRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawLine' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawOval' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawPaint' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawParagraph' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawPath' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawPicture' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawPoints' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawRRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawRawAtlas' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawRawPoints' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawRect' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawShadow' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.drawVertices' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.getDestinationClipBounds' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.getLocalClipBounds' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.getSaveCount' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.getTransform' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.restore' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.restoreToCount' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.rotate' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.save' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.saveLayer' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.scale' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.skew' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.transform' is defined here.
[        ] org-dartlang-sdk:///lib/ui/canvas.dart: Context: 'Canvas.translate' is defined here.
[ +740 ms] lib/main.dart:12:3: Error: The superclass, 'Canvas', has no unnamed constructor that takes no arguments.
[        ]   MyCanvas(super.recorder);
[        ]   ^^^^^^^^
[+2430 ms] Unhandled exception:
[        ] Null check operator used on a null value
[        ] #0      ProgramCompiler._emitSuperConstructorCallIfNeeded (package:dev_compiler/src/kernel/compiler.dart:1778:47)
[        ] #1      ProgramCompiler._emitConstructorBody (package:dev_compiler/src/kernel/compiler.dart:1718:19)
[        ] #2      ProgramCompiler._emitConstructor.<anonymous closure>.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:1665:19)
[        ] #3      ProgramCompiler._superDisallowed (package:dev_compiler/src/kernel/compiler.dart:3827:24)
[        ] #4      ProgramCompiler._emitConstructor.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:1664:15)
[        ] #5      ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2511:25)
[        ] #6      ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3817:18)
[        ] #7      ProgramCompiler._emitConstructor (package:dev_compiler/src/kernel/compiler.dart:1662:16)
[        ] #8      ProgramCompiler._defineConstructors (package:dev_compiler/src/kernel/compiler.dart:1296:28)
[        ] #9      ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:765:19)
[        ] #10     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:692:23)
[        ] #11     List.forEach (dart:core-patch/growable_array.dart:416:8)
[        ] #12     ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:632:23)
[        ] #13     List.forEach (dart:core-patch/growable_array.dart:416:8)
[        ] #14     ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:470:15)
[        ] #15     IncrementalJavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:214:33)
[        ] #16     FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:721:46)
[        ] <asynchronous suspension>
[        ] #17     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:614:9)
[        ] <asynchronous suspension>
[        ] #18     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1222:11)
[        ] <asynchronous suspension>
[  +22 ms] "flutter run" took 4,547ms.
[   +2 ms] the Dart compiler exited unexpectedly.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      DefaultResidentCompiler._compile.<anonymous closure> (package:flutter_tools/src/compile.dart:820:13)
           #2      _rootRun (dart:async/zone.dart:1390:47)
           #3      _CustomZone.run (dart:async/zone.dart:1300:19)
           #4      _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
           #5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
           #6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
           #7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
           #8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
           #9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
           #10     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
           #11     _LineSplitterSink.close (dart:convert/line_splitter.dart:137:11)
           #12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
           #13     _rootRun (dart:async/zone.dart:1390:47)
           #14     _CustomZone.run (dart:async/zone.dart:1300:19)
           #15     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
           #16     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
           #17     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
           #18     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
           #19     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
           #20     _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
           #21     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
           #22     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:305:20)
           #23     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:81:18)
           #24     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
           #25     _rootRun (dart:async/zone.dart:1390:47)
           #26     _CustomZone.run (dart:async/zone.dart:1300:19)
           #27     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
           #28     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
           #29     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
           #30     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
           #31     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
           #32     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
           #33     _StreamController.close (dart:async/stream_controller.dart:630:5)
           #34     _Socket._onData (dart:io-patch/socket_patch.dart:2362:21)
           #35     _rootRunUnary (dart:async/zone.dart:1414:13)
           #36     _CustomZone.runUnary (dart:async/zone.dart:1307:19)
           #37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1216:7)
           #38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
           #39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
           #40     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
           #41     _StreamController._add (dart:async/stream_controller.dart:648:7)
           #42     _StreamController.add (dart:async/stream_controller.dart:596:5)
           #43     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1884:35)
           #44     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1327:18)
           #45     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
           #46     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
           #47     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
           #48     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)
           
           
[   +1 ms] Waiting for connection from debug service on Chrome... (completed in 4.1s)
[        ] Synced 0.0MB.
[        ] Failed to compile application.
[  +78 ms] ensureAnalyticsSent: 80ms
[        ] Running 1 shutdown hook
[   +1 ms] Shutdown hooks complete
[        ] exiting with code 1
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
% flutter analyze
Analyzing web_canvas...                                                 

   info • Don't invoke 'print' in production code • lib/main.dart:7:3 • avoid_print

1 issue found. (ran in 1.1s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
% flutter doctor -v
[✓] Flutter (Channel beta, 3.7.0-1.1.pre, on macOS 13.0.1 22A400 darwin-arm64, locale ko-KR)
    • Flutter version 3.7.0-1.1.pre on channel beta at /Users/anhtuan/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e599f02c7a (3 days ago), 2022-12-08 01:07:24 +0530
    • Engine revision 4971c5b2e7
    • Dart version 2.19.0 (build 2.19.0-444.1.beta)
    • DevTools version 2.20.0

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/anhtuan/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.74.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.54.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.98

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
```

</details>

It compiles and runs totally fine on Android/iOS.