BuildContext.fromMap constructor
BuildContext.fromMap(
- Map<String, dynamic> map
)
Implementation
factory BuildContext.fromMap(Map<String, dynamic> map) {
bool hasError = false;
String errorMessage =
"The following keys don't have a value in the provided Map:\n";
if (map['rootLibraryFileUri'] == null) {
hasError = true;
errorMessage += "rootLibraryFileUri\n";
}
if (map['buildDirectoryUri'] == null) {
hasError = true;
errorMessage += "buildDirectoryUri\n";
}
if (map['executableUri'] == null) {
hasError = true;
errorMessage += "executableUri\n";
}
if (map['source'] == null) {
hasError = true;
errorMessage += "source\n";
}
if (map['forTests'] == null) {
hasError = true;
errorMessage += "forTests\n";
}
if (hasError) {
throw ArgumentError(errorMessage);
}
return BuildContext(
Uri.parse(map['rootLibraryFileUri']),
Uri.parse(map['buildDirectoryUri']),
Uri.parse(map['executableUri']),
map['source'],
forTests: map['forTests']);
}