MaterialFile.parse constructor

MaterialFile.parse(
  1. String source
)

Reads source, a material file's text.

Implementation

factory MaterialFile.parse(String source) {
  final Object? json;
  try {
    json = jsonDecode(source);
  } on FormatException catch (e) {
    throw FormatException('This material is not JSON: ${e.message}');
  }
  if (json is! Map) {
    throw const FormatException('A material file holds a JSON object.');
  }
  return MaterialFile.fromJson(json);
}