Create an instance of an Generic Class from a String in Dart? [duplicate]

戏子无情 提交于 2019-12-25 05:18:51

问题


Hello from here I know that I can create an instance from a String:

How to get a Class name dynamically (from a string) in Dart, then create an instance?

but How do I create an instance of a Generic class from a String, ie:

var class_name = "GenericController<Book>"; // user input here
new class_name();

回答1:


This is not currently possible (as you probably noticed). There's an open case in the Dart issue tracker you should Star to show your interest:

https://code.google.com/p/dart/issues/detail?id=12921



来源:https://stackoverflow.com/questions/25316086/create-an-instance-of-an-generic-class-from-a-string-in-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!