end method
Ends a map or list.
Implementation
Future<void> end() async {
_checkWrite();
if (_stack.isEmpty) {
throw AssertionError('end was called before a list or map was started');
}
final last = _stack.removeLast();
if (last.hasKey) {
throw AssertionError(
'end was called after a key was written without a value',
);
}
await _writeRawString(last.isMap ? '}' : ']');
if (_stack.isEmpty) {
await _stream.close();
}
}