use null aware operators (#32711)

* use null aware operators

* rollback changes about null-aware operator

* disable lint prefer_is_not_empty
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 2af2f96..5b6de5d 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -139,7 +139,7 @@
     # - prefer_int_literals # not yet tested
     # - prefer_interpolation_to_compose_strings # not yet tested
     - prefer_is_empty
-    - prefer_is_not_empty
+    # - prefer_is_not_empty # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
     - prefer_iterable_whereType
     # - prefer_mixin # https://github.com/dart-lang/language/issues/32
     - prefer_null_aware_operators
diff --git a/dev/devicelab/lib/framework/adb.dart b/dev/devicelab/lib/framework/adb.dart
index 3f0bbde..9e4b8f0 100644
--- a/dev/devicelab/lib/framework/adb.dart
+++ b/dev/devicelab/lib/framework/adb.dart
@@ -470,10 +470,7 @@
 
 /// Path to the `adb` executable.
 String get adbPath {
-  final String androidHome =
-      Platform.environment['ANDROID_HOME'] != null
-          ? Platform.environment['ANDROID_HOME']
-          : Platform.environment['ANDROID_SDK_ROOT'];
+  final String androidHome = Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT'];
 
   if (androidHome == null)
     throw 'The ANDROID_SDK_ROOT and ANDROID_HOME environment variables are '
diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart
index 64a2f2f..7b02d23 100644
--- a/packages/flutter/lib/src/material/data_table.dart
+++ b/packages/flutter/lib/src/material/data_table.dart
@@ -739,7 +739,7 @@
   void didUpdateWidget(_SortArrow oldWidget) {
     super.didUpdateWidget(oldWidget);
     bool skipArrow = false;
-    final bool newDown = widget.down != null ? widget.down : _down;
+    final bool newDown = widget.down ?? _down;
     if (oldWidget.visible != widget.visible) {
       if (widget.visible && (_opacityController.status == AnimationStatus.dismissed)) {
         _orientationController.stop();
diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart
index f0bf07e..fb7fc4b 100644
--- a/packages/flutter/lib/src/material/list_tile.dart
+++ b/packages/flutter/lib/src/material/list_tile.dart
@@ -782,7 +782,7 @@
   }
 
   bool _isDenseLayout(ListTileTheme tileTheme) {
-    return dense != null ? dense : (tileTheme?.dense ?? false);
+    return dense ?? tileTheme?.dense ?? false;
   }
 
   TextStyle _titleTextStyle(ThemeData theme, ListTileTheme tileTheme) {
diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart
index eeb2d0e..af16e10 100644
--- a/packages/flutter/lib/src/painting/image_stream.dart
+++ b/packages/flutter/lib/src/painting/image_stream.dart
@@ -202,7 +202,7 @@
   /// will go from being different than other [ImageStream]'s keys to
   /// potentially being the same as others'. No notification is sent when this
   /// happens.
-  Object get key => _completer != null ? _completer : this;
+  Object get key => _completer ?? this;
 
   @override
   void debugFillProperties(DiagnosticPropertiesBuilder properties) {
diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart
index 16817da..abcc350 100644
--- a/packages/flutter/lib/src/rendering/box.dart
+++ b/packages/flutter/lib/src/rendering/box.dart
@@ -109,10 +109,10 @@
   const BoxConstraints.tightFor({
     double width,
     double height,
-  }) : minWidth = width != null ? width : 0.0,
-       maxWidth = width != null ? width : double.infinity,
-       minHeight = height != null ? height : 0.0,
-       maxHeight = height != null ? height : double.infinity;
+  }) : minWidth = width ?? 0.0,
+       maxWidth = width ?? double.infinity,
+       minHeight = height ?? 0.0,
+       maxHeight = height ?? double.infinity;
 
   /// Creates box constraints that require the given width or height, except if
   /// they are infinite.
@@ -143,10 +143,10 @@
   const BoxConstraints.expand({
     double width,
     double height,
-  }) : minWidth = width != null ? width : double.infinity,
-       maxWidth = width != null ? width : double.infinity,
-       minHeight = height != null ? height : double.infinity,
-       maxHeight = height != null ? height : double.infinity;
+  }) : minWidth = width ?? double.infinity,
+       maxWidth = width ?? double.infinity,
+       minHeight = height ?? double.infinity,
+       maxHeight = height ?? double.infinity;
 
   /// The minimum width that satisfies the constraints.
   final double minWidth;
diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart
index 3a059c2..7a6bf1e 100644
--- a/packages/flutter/lib/src/rendering/proxy_box.dart
+++ b/packages/flutter/lib/src/rendering/proxy_box.dart
@@ -2965,7 +2965,7 @@
       markNeedsSemanticsUpdate();
   }
 
-  bool get _effectiveIgnoringSemantics => ignoringSemantics == null ? ignoring : ignoringSemantics;
+  bool get _effectiveIgnoringSemantics => ignoringSemantics ?? ignoring;
 
   @override
   bool hitTest(BoxHitTestResult result, { Offset position }) {
@@ -3171,7 +3171,7 @@
       markNeedsSemanticsUpdate();
   }
 
-  bool get _effectiveIgnoringSemantics => ignoringSemantics == null ? absorbing : ignoringSemantics;
+  bool get _effectiveIgnoringSemantics => ignoringSemantics ?? absorbing;
 
   @override
   bool hitTest(BoxHitTestResult result, { Offset position }) {
diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart
index 19bc64c..79ddc24 100644
--- a/packages/flutter/lib/src/semantics/semantics.dart
+++ b/packages/flutter/lib/src/semantics/semantics.dart
@@ -1949,12 +1949,12 @@
       textDirection: data.textDirection,
       textSelectionBase: data.textSelection != null ? data.textSelection.baseOffset : -1,
       textSelectionExtent: data.textSelection != null ? data.textSelection.extentOffset : -1,
-      platformViewId: data.platformViewId != null ? data.platformViewId : -1,
-      scrollChildren: data.scrollChildCount != null ? data.scrollChildCount : 0,
-      scrollIndex: data.scrollIndex != null ? data.scrollIndex : 0 ,
-      scrollPosition: data.scrollPosition != null ? data.scrollPosition : double.nan,
-      scrollExtentMax: data.scrollExtentMax != null ? data.scrollExtentMax : double.nan,
-      scrollExtentMin: data.scrollExtentMin != null ? data.scrollExtentMin : double.nan,
+      platformViewId: data.platformViewId ?? -1,
+      scrollChildren: data.scrollChildCount ?? 0,
+      scrollIndex: data.scrollIndex ?? 0 ,
+      scrollPosition: data.scrollPosition ?? double.nan,
+      scrollExtentMax: data.scrollExtentMax ?? double.nan,
+      scrollExtentMin: data.scrollExtentMin ?? double.nan,
       transform: data.transform?.storage ?? _kIdentityTransform,
       elevation: data.elevation,
       thickness: data.thickness,
diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart
index 75e260f..dded9e4 100644
--- a/packages/flutter/lib/src/widgets/fade_in_image.dart
+++ b/packages/flutter/lib/src/widgets/fade_in_image.dart
@@ -558,7 +558,7 @@
     return Semantics(
       container: _semanticLabel != null,
       image: true,
-      label: _semanticLabel == null ? '' : _semanticLabel,
+      label: _semanticLabel ?? '',
       child: image,
     );
   }
diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart
index 4bfbb6b..c272aff 100644
--- a/packages/flutter/lib/src/widgets/image.dart
+++ b/packages/flutter/lib/src/widgets/image.dart
@@ -710,7 +710,7 @@
     return Semantics(
       container: widget.semanticLabel != null,
       image: true,
-      label: widget.semanticLabel == null ? '' : widget.semanticLabel,
+      label: widget.semanticLabel ?? '',
       child: image,
     );
   }
diff --git a/packages/flutter/test/widgets/slivers_keepalive_test.dart b/packages/flutter/test/widgets/slivers_keepalive_test.dart
index 53750ba..83a05a6 100644
--- a/packages/flutter/test/widgets/slivers_keepalive_test.dart
+++ b/packages/flutter/test/widgets/slivers_keepalive_test.dart
@@ -460,9 +460,7 @@
                     return children[index];
                   },
                   childCount: children.length,
-                  findChildIndexCallback: (Key key) {
-                    return _mapKeyToIndex[key] == null ? -1 : _mapKeyToIndex[key];
-                  }
+                  findChildIndexCallback: (Key key) => _mapKeyToIndex[key] ?? -1,
                 ),
               )
             ],
diff --git a/packages/flutter_tools/lib/src/base/config.dart b/packages/flutter_tools/lib/src/base/config.dart
index 388e989..b3a505d 100644
--- a/packages/flutter_tools/lib/src/base/config.dart
+++ b/packages/flutter_tools/lib/src/base/config.dart
@@ -46,6 +46,5 @@
 
 String _userHomeDir() {
   final String envKey = platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
-  final String value = platform.environment[envKey];
-  return value == null ? '.' : value;
+  return platform.environment[envKey] ?? '.';
 }
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart
index 428e154..5fed6ac 100644
--- a/packages/flutter_tools/lib/src/ios/simulators.dart
+++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -288,7 +288,7 @@
     if (isSupported())
       return 'Supported';
 
-    return _supportMessage != null ? _supportMessage : 'Unknown';
+    return _supportMessage ?? 'Unknown';
   }
 
   @override
diff --git a/packages/flutter_tools/lib/src/test/event_printer.dart b/packages/flutter_tools/lib/src/test/event_printer.dart
index dee2d00..a3f4cc1 100644
--- a/packages/flutter_tools/lib/src/test/event_printer.dart
+++ b/packages/flutter_tools/lib/src/test/event_printer.dart
@@ -8,7 +8,7 @@
 
 /// Prints JSON events when running a test in --machine mode.
 class EventPrinter extends TestWatcher {
-  EventPrinter({StringSink out}) : _out = out == null ? stdout: out;
+  EventPrinter({StringSink out}) : _out = out ?? stdout;
 
   final StringSink _out;
 
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart
index b2ef9c4..6d1503f 100644
--- a/packages/flutter_tools/lib/src/version.dart
+++ b/packages/flutter_tools/lib/src/version.dart
@@ -105,7 +105,7 @@
   @override
   String toString() {
     final String versionText = frameworkVersion == 'unknown' ? '' : ' $frameworkVersion';
-    final String flutterText = 'Flutter$versionText • channel $channel • ${repositoryUrl == null ? 'unknown source' : repositoryUrl}';
+    final String flutterText = 'Flutter$versionText • channel $channel • ${repositoryUrl ?? 'unknown source'}';
     final String frameworkText = 'Framework • revision $frameworkRevisionShort ($frameworkAge) • $frameworkCommitDate';
     final String engineText = 'Engine • revision $engineRevisionShort';
     final String toolsText = 'Tools • Dart $dartSdkVersion';
diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart
index 4290f6b..6ba3677 100644
--- a/packages/flutter_tools/lib/src/vmservice.dart
+++ b/packages/flutter_tools/lib/src/vmservice.dart
@@ -718,13 +718,11 @@
 
   /// The number of bytes allocated (e.g. by malloc) in the native heap.
   int _heapAllocatedMemoryUsage;
-  int get heapAllocatedMemoryUsage {
-    return _heapAllocatedMemoryUsage == null ? 0 : _heapAllocatedMemoryUsage;
-  }
+  int get heapAllocatedMemoryUsage => _heapAllocatedMemoryUsage ?? 0;
 
   /// The peak resident set size for the process.
   int _maxRSS;
-  int get maxRSS => _maxRSS == null ? 0 : _maxRSS;
+  int get maxRSS => _maxRSS ?? 0;
 
   // The embedder's name, Flutter or dart_runner.
   String _embedder;
diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart
index 8e9e3a8..4d2f5e7 100644
--- a/packages/flutter_tools/test/src/context.dart
+++ b/packages/flutter_tools/test/src/context.dart
@@ -121,7 +121,7 @@
         },
       );
     });
-  }, timeout: timeout != null ? timeout : const Timeout(Duration(seconds: 60)),
+  }, timeout: timeout ?? const Timeout(Duration(seconds: 60)),
       testOn: testOn, skip: skip);
 }