Comment créer les variables privées de Dart?

Je veux créer une variable privée mais je ne peux pas.

Voici mon code:

void main() {
  var b = new B();
  b.testB();    
}

class A {
  int _private = 0;

  testA() {
    print('int value: $_private');
    _private = 5;
  }
}

class B extends A {
  String _private;

  testB() {
    _private = 'Hello';
    print('String value: $_private');
    testA();
    print('String value: $_private');
  }
}

Lorsque j'exécute ce code, j'obtiens le résultat suivant:

String value: Hello
int value: Hello
Breaking on exception: type 'int' is not a subtype of type 'String' of 'value'.

Aussi j'ai pas d'erreur ou de mises en garde lors de la modification de ce code source.

Comment puis-je créer une variable privée dans Dart?

InformationsquelleAutor | 2013-07-05