readSource function

Future<String> readSource(
  1. String source
)

source is the location of a file. source can be a File.path, ProjectFilePath or Uri

Implementation

Future<String> readSource(String source) async {
  try {
    return await readFromFilePath(source);
  } on UnsupportedSourceException {
    try {
      return await readFromHttpUri(source);
    } on UnsupportedSourceException {
      try {
        return await readFromFileUri(source);
      } on Exception catch (e) {
        var message = e
            .toString()
            .replaceFirst('Exception: ', '')
            .replaceAll('\r', '')
            .replaceAll('\n', '');
        throw Exception(message);
      }
    }
  }
}