3

I installed webdev to run dart web but when I want to run webdev it's showing an error:

Building package executable... 
Failed to build webdev:webdev:
../../.pub-cache/hosted/pub.dartlang.org/dds-2.1.6/lib/src/cpu_samples_manager.dart:54:21: Error: Type 'CpuSamplesEvent' not found.
  void cacheSamples(CpuSamplesEvent samples) {
                    ^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dds-2.1.6/lib/src/cpu_samples_manager.dart:54:21: Error: 'CpuSamplesEvent' isn't a type.
  void cacheSamples(CpuSamplesEvent samples) {
                    ^^^^^^^^^^^^^^^

How can I fix it?

Shahryar Pirooz
  • 410
  • 3
  • 10

2 Answers2

5

I just fixed that.

I edited cpu_samples_manager.dart in ~/.pub-cache/hosted/pub.dartlang.org/dds-2.1.6/lib/src/ and replace CpuSamplesEvent with var. ;)

anyway, if there is a better solution, please let me know.

Shahryar Pirooz
  • 410
  • 3
  • 10
3

This issue occurs with 2.14.1 of dart, and maybe previous versions. You can update to 2.15.1 of Dart and this will disappear.

There is an official fix in DDS 2.1.6+1 which also fixes the issue, but webdev loads 2.1.6.

You can make it use the new version by calling pub global activate webdev then after you have received the error call pub global activate dds 2.1.6+1 then re-run pub global activate webdev which will succeed.

I put issue on their SDK github, hopefully this will be resolved soon.

AndrewL
  • 334
  • 2
  • 13
  • now it's working, thank you. – Shahryar Pirooz Dec 21 '21 at 06:34
  • 2
    "You can update to 2.15.1 of Dart and this will disappear." This does not seem to be the case. I still get the same error with 2.15.1. Also, the fix does not work when webdev actually runs. – Mark Dec 24 '21 at 15:37
  • This has been patched now by dart, see https://github.com/dart-lang/sdk/issues/47978 If you still have issues deactivate webdev, then run `dart pub cache clean` and then reactivate webdev, it should pull that patched version. – AndrewL Jan 10 '22 at 01:47