Home > OS >  Using variables in string that is read from file
Using variables in string that is read from file

Time:01-13

I have a Flutter project, that has to read Strings from a file. These strings need to have variables in them. For example, if i have a text file with the string "this is test $i", where i is a var in my flutter code with the value 1, the string value should be "this is test 1". Is there a way to do this?

CodePudding user response:

If you read these values from .txt file, '$i' will not be read as a variable anymore, so i suggest replacing '$i' with a keyword you select, and replacing the keyword with your variable after you fetch the file.

  • Related