[inspect][dart] Add an optional parameter that allows specification of a String or ByteData value on property creation.

This is purely for client convenience, as it makes the callsite more straightforward for the use case of creating a property with a known key and value pair.

  var property = inspect.createStringProperty('foo-name')..value = 'foo-value';

becomes

  var property = inspect.createStringProperty('foo-name', value: 'foo-value');

CF-602 #comment

Change-Id: I2a8263cd509830c6ad5d83c7202fb68fe791c970
diff --git a/public/dart/fuchsia_inspect/examples/inspect_mod/lib/src/inspect_example_app.dart b/public/dart/fuchsia_inspect/examples/inspect_mod/lib/src/inspect_example_app.dart
index 3b6a34a..273c5c3 100644
--- a/public/dart/fuchsia_inspect/examples/inspect_mod/lib/src/inspect_example_app.dart
+++ b/public/dart/fuchsia_inspect/examples/inspect_mod/lib/src/inspect_example_app.dart
@@ -30,7 +30,7 @@
 
   /// Initializes the [Inspect] metrics for this widget.
   void _initMetrics() {
-    _inspectNode.createStringProperty('app-color').value = '$_appColor';
+    _inspectNode.createStringProperty('app-color', value: '$_appColor');
   }
 }
 
@@ -39,7 +39,7 @@
   final inspect.Node inspectNode;
 
   _InspectHomePage({Key key, this.title, this.inspectNode}) : super(key: key) {
-    inspectNode.createStringProperty('title').value = title;
+    inspectNode.createStringProperty('title', value: title);
   }
 
   @override
@@ -62,8 +62,8 @@
   int _colorIndex = 0;
 
   _InspectHomePageState(this._inspectNode) {
-    _backgroundProperty = _inspectNode.createStringProperty('background-color')
-      ..value = '$_backgroundColor';
+    _backgroundProperty = _inspectNode.createStringProperty('background-color',
+        value: '$_backgroundColor');
   }
 
   Color get _backgroundColor => _colors[_colorIndex];
diff --git a/public/dart/fuchsia_inspect/lib/src/inspect/node.dart b/public/dart/fuchsia_inspect/lib/src/inspect/node.dart
index 473127f..d51384d 100644
--- a/public/dart/fuchsia_inspect/lib/src/inspect/node.dart
+++ b/public/dart/fuchsia_inspect/lib/src/inspect/node.dart
@@ -28,17 +28,35 @@
 
   /// Creates a [StringProperty] with [name] on this node.
   ///
+  /// Optionally sets the [value], if specified.
+  ///
   /// Does not check whether the property already exists. This method is not
   /// idempotent and calling it multiple times with the same [name] will
   /// create multiple [StringProperty]s.
-  StringProperty createStringProperty(String name) =>
-      StringProperty._(name, index, _writer);
+  StringProperty createStringProperty(String name, {String value}) {
+    var property = StringProperty._(name, index, _writer);
+
+    if (value != null) {
+      property.value = value;
+    }
+
+    return property;
+  }
 
   /// Creates a [ByteDataProperty] with [name] on this node.
   ///
+  /// Optionally sets the [value], if specified.
+  ///
   /// Does not check whether the property already exists. This method is not
   /// idempotent and calling it multiple times with the same [name] will
   /// create multiple [ByteDataProperty]s.
-  ByteDataProperty createByteDataProperty(String name) =>
-      ByteDataProperty._(name, index, _writer);
+  ByteDataProperty createByteDataProperty(String name, {ByteData value}) {
+    var property = ByteDataProperty._(name, index, _writer);
+
+    if (value != null) {
+      property.value = value;
+    }
+
+    return property;
+  }
 }
diff --git a/public/dart/fuchsia_inspect/test/inspect/property_test.dart b/public/dart/fuchsia_inspect/test/inspect/property_test.dart
index 55486d6..b533fcb 100644
--- a/public/dart/fuchsia_inspect/test/inspect/property_test.dart
+++ b/public/dart/fuchsia_inspect/test/inspect/property_test.dart
@@ -25,7 +25,7 @@
 
   group('String properties', () {
     test('are written to the VMO when the value is set', () {
-      var property = node.createStringProperty('color')..value = 'fuchsia';
+      var property = node.createStringProperty('color', value: 'fuchsia');
 
       expect(readProperty(vmo, property.index),
           equalsByteData(toByteData('fuchsia')));
@@ -72,14 +72,14 @@
   group('ByteData properties', () {
     test('are written to the VMO when the value is set', () {
       var bytes = toByteData('fuchsia');
-      var property = node.createByteDataProperty('color')..value = bytes;
+      var property = node.createByteDataProperty('color', value: bytes);
 
       expect(readProperty(vmo, property.index), equalsByteData(bytes));
     });
 
     test('can be mutated', () {
       var pancakes = toByteData('pancakes');
-      var property = node.createByteDataProperty('breakfast')..value = pancakes;
+      var property = node.createByteDataProperty('breakfast', value: pancakes);
 
       expect(readProperty(vmo, property.index), equalsByteData(pancakes));