How to call a named constructor from a generic function in Flutter?

Posted by Jessica Taylor | Updated on

Want to call a named constructor from a generic function in Flutter? There is probably a way to do that on the server, where dart:mirrors (reflection) is available (not tried myself yet), but not in Flutter or the browser.

You would need to maintain a map of types to factory functions:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers