SourceEdit.fromJson constructor
Constructs a SourceEdit from JSON.
Example:
final edit = {
'offset': 1,
'length': 2,
'replacement': 'replacement string'
};
final sourceEdit = SourceEdit.fromJson(edit);
Implementation
factory SourceEdit.fromJson(Map<String, dynamic> json) {
final offset = json['offset'];
final length = json['length'];
final replacement = json['replacement'];
if (offset is int && length is int && replacement is String) {
return SourceEdit(offset, length, replacement);
}
throw const FormatException('Invalid JSON passed to SourceEdit');
}