I'm developing a serialization library that works in flutter so I'm avoiding Mirrors and would like to know what's possible with runtime generics in Dart/flutter to find out what needs to be code-gen'ed and what can be automated with generic routines.Firstly how can we can get the runtime time of a generic argument?T create<T>() {var runtimeTypeOfT = ... ?}
T create<T>() {var runtimeTypeOfT = T;}
Is it possible to create a new instance of T where T has an empty constructor, e.g:T create<T>() {var instance = new T();return instance;}This is possible in C# without reflection by using the `where T : new()` type constraint, how can we do this in Dart/Flutter?
Can we create a generic factory function which creates a generic list with the runtime argType?List createList(String argType) {var newGenericList = ... // create List<argType>?return newGenericList;}So that we can could use it to create generic lists like:List<int> intList = createList("int");List<String> stringList = createList("String");
As a current workaround/hack I'm generating a dictionary of factory constructors like:{'List<String>': () => new List<String>(),'Map<String,int>': () => new Map<String,int>(),}