For a cross-platform (iOS, android) project I consider using Dart with UI-Programming in Flutter.
For straight-forward translation of present Kotlin code, I want to call functions by their function name. To be more precise, I am looking for how to write the function getFunctionByName such that the following code prints "The answer is 42."?
void function42(String s) {
print(s + " 42.");
}
void main() {
int number = 42;
String calculatedFunctionName = "function" + number.toString();
String calculatedArgument = "The answer is";
Function f = getFunctionByName(calculatedFunctionName);
f(calculatedArgument);
}
What I try to achieve works in Kotlin and seems to work in Dart, but when I tried the linked Dart code in a Flutter project, the import
import 'dart:mirrors';
does not work for me. There is a whole thread about reflection in Flutter, which I interpret such that at the time of writing reflection does not work in Flutter. But maybe there is a workaround for the specific thing I want to do?