Allow null content when writing the body. (#16)

diff --git a/lib/src/sync_http.dart b/lib/src/sync_http.dart
index 168625b..a2e4e7f 100644
--- a/lib/src/sync_http.dart
+++ b/lib/src/sync_http.dart
@@ -63,9 +63,11 @@
         this._socket = RawSynchronousSocket.connectSync(uri.host, uri.port);
 
   /// Write content into the body of the HTTP request.
-  void write(Object obj) {
+  void write(Object? obj) {
     if (hasBody) {
-      _body!.add(encoding.encoder.convert(obj.toString()));
+      if (obj != null) {
+        _body!.add(encoding.encoder.convert(obj.toString()));
+      }
     } else {
       throw new StateError('write not allowed for method $method');
     }