close method
Closes the writer and waits for listeners of stream to finish.
Implementation
Future<void> close() async {
await _stream.close();
_checkWrite();
if (_stack.isNotEmpty) {
throw AssertionError(
'Attempted to close writer without ending the top-level list or map',
);
} else if (!_hasRootValue) {
throw AssertionError(
'Attempted to close the writer without actually writing a value',
);
}
}