I've been trying to load a text file into a variable, so that I can check if the user's input is valid. However, I've been having difficulty trying to store the output of the rootBundle.loadString
function into a useable String variable, and I'm not sure how to do it.
My code:
Future<String> getFileData(String path) async {
return rootBundle.loadString(path);
}
String text = getFileData("assets/textfile.txt");
How would I store the contents of a text file in a variable as a string type?