Map by Class in Dart -


Dart porting some Java-code and it makes heavy use of these types of maps:
 

Maps & lt; Classroom & lt;? Some classes & gt; Spreads, some other class & gt; Map = new hashmap & lt; & Gt; ();

At the moment it seems impossible in dart. I know that the first level types are proposed to be introduced: which will apply

  class type {@native String toString ());   

So until this proposal is implemented I have created the following class:

  class type {last string classname; Const type (this.classname); String descriptor () = & gt; class name; }   

And get the simple sections of the sections I need it

  type type Please);   

In this way I can use my type as I would use the actual type and switch to later Just remove my solution.

My question: Is there something wrong with doing this mapping (which I am not seeing) or by the way I take it as appropriate to the actual type

-Dart printing-override "> Var map = new map & lt; type, someOtherClass & gt; (); // either map [SomeOtherClass] = new some other class (); // or var example = new SomeOtherClass (); map [instance.runtimeType ] = Example;

update : This build is not currently capable of dart

  map & lt; class & lt;? Some class & gt; spreads , Some other class & gt;   

You have to wait for .type / .class so that it can get a beautiful solution (many of us Dartisans are hoping that it will soon come later), though for the simple case,

  map & lt;? Some classes, some other classes & gt;   

You can do just that

  Maps & lt; SomeClass, SomeOtherClass & gt; A map;   

Any square spread across SomeClass as a dart is going to be SomeClass for example if you use the following code Run in check mode:

  main () {map & lt; Test, string & gt; Mapp = new hashmap   

Then you will get an error:

  type 'Notatest' type is not a sub type 'key 'Test' of '   

Comments