# writeObject method

Future<void> writeObject(

1. Object? obj

)

Writes the string representation of an object.

The string representation is obtained by calling the object's toString method. If the object is null, the string "null" is written.

## Parameters

- `obj`: The object to write

## Example

    final writer = FileWriter('output.txt');
    try {
      await writer.writeObject(42);
      await writer.writeObject(' ');
      await writer.writeObject(3.14);
      await writer.writeObject(' ');
      await writer.writeObject(true);
      await writer.flush();
    } finally {
      await writer.close();
    }

Throws IOException if an I/O error occurs. Throws StreamClosedException if the writer has been closed.

## Implementation

    Future<void> writeObject(Object? obj) async {
      await write(obj?.toString() ?? 'null');
    }