I'm not sure if this is a bug in the Dart Editor, or a problem with the way I'm using part of, but given the following project structure:

myapp/
    pubspec.yaml
    pubspec.lock
    asset/
    packages/
    build/
    web/
        Fizz.dart
        Buzz.dart

Where Fizz.dart is:

library fizz;

void herp() {
    print("Herp!");
}

and where Buzz.dart is:

library buzz;

void derp() {
    String x = "Derp!";
    print(x);
}

If I change Buzz.dart to intentionally have a compiler error:

library buzz;

void derp() {
    djedString x = "Derp!";  // Produces "Undefined class 'djedString'" error
    print(x);
}

Then Dart Editor underlines djedString with a red line and gives the above compiler error:

Undefined class 'djedString'

But if I then change Buzz.dart to be a part of the fizz library:

part of fizz;

void derp() {
    djedString x = "Derp!";  // Perfectly fine! No errors!
    print(x);
}

Dart Editor then removes the compiler error, and in fact, stops looking for warnings/errors altogether (inside the file).

Is this a bug or am I not using part of correctly?

有帮助吗?

解决方案

part of aaa; have to be used with part "xxx";.

a.dart

library a;

part 'a1.dart';

a1.dart

part of a;

// content of the part
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top