defaultFileLoadBuilder function

Future<String> defaultFileLoadBuilder(
  1. String path
)

A default file load builder that reads the contents of a file from the specified path.

This function is used for loading data from local files.

  • path: The path to the file to be read.

Returns a Future that completes with the contents of the file as a string.

Implementation

Future<String> defaultFileLoadBuilder(String path) async {
  final File file = File(path);
  bool exists = await file.exists();
  if (exists) {
    String readAsString = await file.readAsString();
    return readAsString;
  }
  return throw Exception('File not found');
}