[pigeon] Made sure that you can nil out the message handler (#112)

diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart
index cfa325a..b0d7cd2 100644
--- a/packages/pigeon/lib/generator_tools.dart
+++ b/packages/pigeon/lib/generator_tools.dart
@@ -6,6 +6,9 @@
 import 'dart:io';
 import 'ast.dart';
 
+/// The current version of pigeon.
+const String pigeonVersion = '0.1.0-experimental.3';
+
 /// Read all the content from [stdin] to a String.
 String readStdin() {
   final List<int> bytes = <int>[];
@@ -119,7 +122,7 @@
 
 /// Warning printed at the top of all generated code.
 const String generatedCodeWarning =
-    'Autogenerated from Pigeon, do not edit directly.';
+    'Autogenerated from Pigeon (v$pigeonVersion), do not edit directly.';
 
 /// String to be printed after `generatedCodeWarning`.
 const String seeAlsoWarning = 'See also: https://pub.dev/packages/pigeon';
diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart
index c5c81da..9737739 100644
--- a/packages/pigeon/lib/objc_generator.dart
+++ b/packages/pigeon/lib/objc_generator.dart
@@ -166,14 +166,22 @@
         indent.dec();
         indent.dec();
 
-        indent.write(
-            '[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) ');
-        indent.scoped('{', '}];', () {
-          final String argType = _className(options.prefix, func.argType);
-          final String returnType = _className(options.prefix, func.returnType);
-          indent.writeln('$argType *input = [$argType fromMap:message];');
-          indent.writeln('$returnType *output = [api ${func.name}:input];');
-          indent.writeln('callback([output toMap]);');
+        indent.write('if (api) ');
+        indent.scoped('{', '}', () {
+          indent.write(
+              '[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) ');
+          indent.scoped('{', '}];', () {
+            final String argType = _className(options.prefix, func.argType);
+            final String returnType =
+                _className(options.prefix, func.returnType);
+            indent.writeln('$argType *input = [$argType fromMap:message];');
+            indent.writeln('$returnType *output = [api ${func.name}:input];');
+            indent.writeln('callback([output toMap]);');
+          });
+        });
+        indent.write('else ');
+        indent.scoped('{', '}', () {
+          indent.writeln('[channel setMessageHandler:nil];');
         });
       });
     }