How can I get variable value from a text string?

Viewed 141

I have a constants file with text values, for example:

const String loginIntro1 = "Login to account";
const String loginButton = "Login";

And I also have a Map containing similar info, for example:

{"loginIntro1":"Login to account","loginButton":"Login"}

The idea is that the Map (derived from a JSON file) takes precedence, but if the value doesn't exist, the constants value is used instead.

In my text widget, I want to grab the text by a method call, such as:

getText('loginIntro1');

Is this even possible? How can I get the value from the constants file with a String, rather than a direct reference to the variable? Perhaps I'm missing a much simpler way of achieving this!

0 Answers
Related