Enable null-safety, prep to release v1 (dart-lang/timing#16)

diff --git a/pkgs/timing/.github/workflows/test-package.yml b/pkgs/timing/.github/workflows/test-package.yml
index b04d6e2..173d3f4 100644
--- a/pkgs/timing/.github/workflows/test-package.yml
+++ b/pkgs/timing/.github/workflows/test-package.yml
@@ -20,13 +20,12 @@
     strategy:
       fail-fast: false
       matrix:
-        sdk: [dev]
-        version: [latest]
+        sdk: [2.12.0, dev]
     steps:
       - uses: actions/checkout@v2
-      - uses: dart-lang/setup-dart@v0.1
+      - uses: dart-lang/setup-dart@v1.0
         with:
-          channel: ${{ matrix.sdk }}
+          sdk: ${{ matrix.sdk }}
       - id: install
         name: Install dependencies
         run: dart pub get
@@ -48,21 +47,14 @@
       matrix:
         # Add macos-latest and/or windows-latest if relevant for this package.
         os: [ubuntu-latest]
-        sdk: [dev]
-        version: [latest]
-        include:
-          - os: ubuntu-latest
-            sdk: stable
-            version: 2.2.0
+        sdk: [2.12.0, dev]
     steps:
       - uses: actions/checkout@v2
-      - uses: cedx/setup-dart@v2 # TODO(dart-lang/setup-dart#3): use the official setup-dart action
+      - uses: dart-lang/setup-dart@v1.0
         with:
-          release-channel: ${{ matrix.sdk }}
-          version: ${{ matrix.version }}
+          sdk: ${{ matrix.sdk }}
       - id: install
-        name: Install dependencies
         run: pub get
       - name: Run VM tests
-        run: pub run test --platform vm
+        run: dart test --platform vm
         if: always() && steps.install.outcome == 'success'
diff --git a/pkgs/timing/CHANGELOG.md b/pkgs/timing/CHANGELOG.md
index c809220..0ceb3d7 100644
--- a/pkgs/timing/CHANGELOG.md
+++ b/pkgs/timing/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.0.0
+
+- Enable null safety.
+- Require Dart `2.12`.
+
 ## 0.1.1+3
 
 - Allow `package:json_annotation` `'>=1.0.0 <5.0.0'`.
diff --git a/pkgs/timing/analysis_options.yaml b/pkgs/timing/analysis_options.yaml
index 210b18f..9f7e921 100644
--- a/pkgs/timing/analysis_options.yaml
+++ b/pkgs/timing/analysis_options.yaml
@@ -1,13 +1,16 @@
 include: package:pedantic/analysis_options.yaml
+
 analyzer:
   strong-mode:
     implicit-casts: false
+
 linter:
   rules:
     - always_declare_return_types
     - annotate_overrides
     - avoid_bool_literals_in_conditional_expressions
     - avoid_classes_with_only_static_members
+    - avoid_dynamic_calls
     - avoid_empty_else
     - avoid_function_literals_in_foreach_calls
     - avoid_init_to_null
diff --git a/pkgs/timing/lib/src/clock.dart b/pkgs/timing/lib/src/clock.dart
index 2fdfc7c..6a9d295 100644
--- a/pkgs/timing/lib/src/clock.dart
+++ b/pkgs/timing/lib/src/clock.dart
@@ -13,7 +13,7 @@
 /// Returns the current [DateTime].
 ///
 /// May be overridden for tests using [scopeClock].
-DateTime now() => (Zone.current[_zoneKey] as _Clock ?? _defaultClock)();
+DateTime now() => (Zone.current[_zoneKey] as _Clock? ?? _defaultClock)();
 
 /// Runs [f], with [clock] scoped whenever [now] is called.
 T scopeClock<T>(DateTime Function() clock, T Function() f) =>
diff --git a/pkgs/timing/lib/src/timing.dart b/pkgs/timing/lib/src/timing.dart
index 17e2fb1..013f2f7 100644
--- a/pkgs/timing/lib/src/timing.dart
+++ b/pkgs/timing/lib/src/timing.dart
@@ -12,7 +12,7 @@
 
 /// The timings of an operation, including its [startTime], [stopTime], and
 /// [duration].
-@JsonSerializable(nullable: false)
+@JsonSerializable()
 class TimeSlice {
   /// The total duration of this operation, equivalent to taking the difference
   /// between [stopTime] and [startTime].
@@ -35,7 +35,7 @@
 
 /// The timings of an async operation, consist of several sync [slices] and
 /// includes total [startTime], [stopTime], and [duration].
-@JsonSerializable(nullable: false)
+@JsonSerializable()
 class TimeSliceGroup implements TimeSlice {
   final List<TimeSlice> slices;
 
@@ -96,13 +96,13 @@
 class SyncTimeTracker implements TimeTracker {
   /// When this operation started, call [_start] to set this.
   @override
-  DateTime get startTime => _startTime;
-  DateTime _startTime;
+  DateTime get startTime => _startTime!;
+  DateTime? _startTime;
 
   /// When this operation stopped, call [_stop] to set this.
   @override
-  DateTime get stopTime => _stopTime;
-  DateTime _stopTime;
+  DateTime get stopTime => _stopTime!;
+  DateTime? _stopTime;
 
   /// Start tracking this operation, must only be called once, before [_stop].
   void _start() {
@@ -128,7 +128,7 @@
       throw StateError('Can be only called while tracking');
     }
     final _now = now();
-    final prevSlice = TimeSlice(_startTime, _now);
+    final prevSlice = TimeSlice(_startTime!, _now);
     _startTime = _now;
     return prevSlice;
   }
@@ -147,16 +147,16 @@
   }
 
   @override
-  bool get isStarted => startTime != null;
+  bool get isStarted => _startTime != null;
 
   @override
-  bool get isTracking => startTime != null && stopTime == null;
+  bool get isTracking => _startTime != null && _stopTime == null;
 
   @override
-  bool get isFinished => startTime != null && stopTime != null;
+  bool get isFinished => _startTime != null && _stopTime != null;
 
   @override
-  Duration get duration => stopTime?.difference(startTime);
+  Duration get duration => _stopTime!.difference(_startTime!);
 
   /// Converts to JSON representation
   ///
@@ -324,7 +324,7 @@
     }
   }
 
-  bool _tracking;
+  bool? _tracking;
 
   @override
   bool get isStarted => _tracking != null;
diff --git a/pkgs/timing/lib/src/timing.g.dart b/pkgs/timing/lib/src/timing.g.dart
index 91293b2..64b64ef 100644
--- a/pkgs/timing/lib/src/timing.g.dart
+++ b/pkgs/timing/lib/src/timing.g.dart
@@ -20,7 +20,7 @@
 
 TimeSliceGroup _$TimeSliceGroupFromJson(Map<String, dynamic> json) {
   return TimeSliceGroup(
-    (json['slices'] as List)
+    (json['slices'] as List<dynamic>)
         .map((e) => TimeSlice.fromJson(e as Map<String, dynamic>))
         .toList(),
   );
diff --git a/pkgs/timing/pubspec.yaml b/pkgs/timing/pubspec.yaml
index cbbacc8..08e2442 100644
--- a/pkgs/timing/pubspec.yaml
+++ b/pkgs/timing/pubspec.yaml
@@ -1,18 +1,23 @@
 name: timing
-version: 0.1.1+3
+version: 1.0.0
 description: >-
   A simple package for tracking the performance of synchronous and asynchronous
   actions.
 repository: https://github.com/dart-lang/timing
 
 environment:
-  sdk: ">=2.2.0 <3.0.0"
+  sdk: ">=2.12.0 <3.0.0"
 
 dependencies:
-  json_annotation: '>=1.0.0 <5.0.0'
+  json_annotation: ^4.0.0
 
 dev_dependencies:
   build_runner: ^1.0.0
-  json_serializable: ^3.1.0
+  json_serializable: ^4.0.0
   pedantic: ^1.1.0
   test: ^1.0.0
+
+dependency_overrides:
+  # Remove these when they are updated to support the latest pkg:timing
+  build_runner: ^1.0.0
+  build_runner_core: ^6.0.0
diff --git a/pkgs/timing/test/timing_test.dart b/pkgs/timing/test/timing_test.dart
index 56f5f98..610cfce 100644
--- a/pkgs/timing/test/timing_test.dart
+++ b/pkgs/timing/test/timing_test.dart
@@ -13,12 +13,12 @@
 void _noop() {}
 
 void main() {
-  DateTime time;
+  late DateTime time;
   final startTime = DateTime(2017);
   DateTime fakeClock() => time;
 
-  TimeTracker tracker;
-  TimeTracker nestedTracker;
+  late TimeTracker tracker;
+  late TimeTracker nestedTracker;
 
   T scopedTrack<T>(T Function() f) =>
       scopeClock(fakeClock, () => tracker.track(f));
@@ -222,8 +222,8 @@
   });
 
   group('AsyncTimeTracker', () {
-    AsyncTimeTracker asyncTracker;
-    AsyncTimeTracker nestedAsyncTracker;
+    late AsyncTimeTracker asyncTracker;
+    late AsyncTimeTracker nestedAsyncTracker;
     setUp(() {
       tracker = asyncTracker = AsyncTimeTracker();
       nestedTracker = nestedAsyncTracker = AsyncTimeTracker();