Like the question at Dynamic class method invocation in PHP I want to do this in Dart.
var = "name";
page.${var} = value;
page.save();
Is that possible?
Like the question at Dynamic class method invocation in PHP I want to do this in Dart.
var = "name";
page.${var} = value;
page.save();
Is that possible?
You can use Serializable
For example:
There are several things you can achieve with Mirrors.
Here's an example how to set values of classes and how to call methods dynamically:
In case you wonder,
im
is anInstanceMirror
, which basically reflects thepage
instance.There is also another question: Is there a way to dynamically call a method or set an instance variable in a class in Dart?
You can use Dart Mirror API to do such thing. Mirror API is not fully implemented now but here's how it could work :