Skip to content

Commit c58cf6e

Browse files
authored
Merge null safety branch into master (flutter#18)
1 parent 3b52a74 commit c58cf6e

10 files changed

+80
-31
lines changed

.travis.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
language: dart
22

33
dart:
4-
- dev
5-
- 2.1.1
4+
- preview/raw/2.10.0-0.2-dev
65

76
dart_task:
87
- test: -p vm,chrome
9-
10-
matrix:
11-
include:
12-
- dart: dev
13-
dart_task: dartfmt
14-
- dart: dev
15-
dart_task:
16-
dartanalyzer: --fatal-lints --fatal-warnings .
17-
- dart: 2.1.1
18-
dart_task:
19-
dartanalyzer: --fatal-warnings .
8+
- dartfmt
9+
- dartanalyzer: --fatal-lints --fatal-warnings .
10+
2011

2112
# Only building master means that we don't run two builds for each pull request.
2213
branches:

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0-nullsafety
2+
3+
* Update to null safety.
4+
15
## 1.0.1
26

37
* Update to lowercase Dart core library constants.

analysis_options.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include: package:pedantic/analysis_options.yaml
22
analyzer:
33
strong-mode:
44
implicit-casts: false
5+
enable-experiment:
6+
- non-nullable
57
linter:
68
rules:
79
- always_declare_return_types

lib/src/default.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final _isFinalKey = Object();
2828
///
2929
/// This defaults to the system clock. It can be set within a zone using
3030
/// [withClock].
31-
Clock get clock => Zone.current[_clockKey] as Clock ?? const Clock();
31+
Clock get clock => Zone.current[_clockKey] as Clock? ?? const Clock();
3232

3333
/// Runs [callback] with the given value for the top-level [clock] field.
3434
///

lib/src/stopwatch.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ClockStopwatch implements Stopwatch {
3434

3535
/// The point at which [start] was called most recently, or `null` if this
3636
/// isn't active.
37-
DateTime _start;
37+
DateTime? _start;
3838

3939
ClockStopwatch(this._clock);
4040

@@ -52,7 +52,7 @@ class ClockStopwatch implements Stopwatch {
5252
@override
5353
int get elapsedMicroseconds =>
5454
_elapsed +
55-
(_start == null ? 0 : _clock.now().difference(_start).inMicroseconds);
55+
(_start == null ? 0 : _clock.now().difference(_start!).inMicroseconds);
5656

5757
@override
5858
void start() {

lib/src/utils.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// because quiver is very large and the amount of code we use from it is very
1717
// small.
1818

19-
import 'package:meta/meta.dart';
20-
2119
/// The number of days in each month.
2220
///
2321
/// This array uses 1-based month numbers, i.e. January is the 1-st element in
@@ -57,5 +55,5 @@ bool isLeapYear(int year) =>
5755
/// month back takes us to February 28 (or 29 during a leap year), as February
5856
/// doesn't have 31-st date.
5957
int clampDayOfMonth(
60-
{@required int year, @required int month, @required int day}) =>
58+
{required int year, required int month, required int day}) =>
6159
day.clamp(1, daysInMonth(year, month)) as int;

pubspec.yaml

+59-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
11
name: clock
2-
version: 1.0.2-dev
2+
version: 1.1.0-nullsafety
33
description: A fakeable wrapper for dart:core clock APIs
44
homepage: https://github.com/dart-lang/clock
55

66
environment:
7-
sdk: '>=2.1.1 <3.0.0'
8-
9-
dependencies:
10-
meta: ^1.0.0
7+
# This must remain a tight constraint until nnbd is stable
8+
sdk: '>=2.10.0-0 <2.10.0'
119

1210
dev_dependencies:
1311
test: ^1.0.0
1412
pedantic: ^1.8.0
13+
14+
dependency_overrides:
15+
async:
16+
git: git://github.com/dart-lang/async.git
17+
boolean_selector:
18+
git: git://github.com/dart-lang/boolean_selector.git
19+
charcode:
20+
git: git://github.com/dart-lang/charcode.git
21+
collection:
22+
git: git://github.com/dart-lang/collection.git
23+
js:
24+
git:
25+
url: git://github.com/dart-lang/sdk.git
26+
path: pkg/js
27+
ref: 2-10-pkgs
28+
matcher:
29+
git: git://github.com/dart-lang/matcher.git
30+
meta:
31+
git:
32+
url: git://github.com/dart-lang/sdk.git
33+
path: pkg/meta
34+
ref: 2-10-pkgs
35+
path:
36+
git: git://github.com/dart-lang/path.git
37+
pedantic:
38+
git: git://github.com/dart-lang/pedantic.git
39+
pool:
40+
git: git://github.com/dart-lang/pool.git
41+
source_maps:
42+
git: git://github.com/dart-lang/source_maps.git
43+
source_map_stack_trace:
44+
git: git://github.com/dart-lang/source_map_stack_trace.git
45+
source_span:
46+
git: git://github.com/dart-lang/source_span.git
47+
stack_trace:
48+
git: git://github.com/dart-lang/stack_trace.git
49+
stream_channel:
50+
git: git://github.com/dart-lang/stream_channel.git
51+
string_scanner:
52+
git: git://github.com/dart-lang/string_scanner.git
53+
term_glyph:
54+
git: git://github.com/dart-lang/term_glyph.git
55+
test_api:
56+
git:
57+
url: git://github.com/dart-lang/test.git
58+
path: pkgs/test_api
59+
test_core:
60+
git:
61+
url: git://github.com/dart-lang/test.git
62+
path: pkgs/test_core
63+
test:
64+
git:
65+
url: git://github.com/dart-lang/test.git
66+
path: pkgs/test
67+
typed_data:
68+
git: git://github.com/dart-lang/typed_data.git

test/clock_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import 'package:test/test.dart';
1919
import 'utils.dart';
2020

2121
void main() {
22-
Clock clock;
22+
late Clock clock;
2323
setUp(() {
2424
clock = Clock.fixed(date(2013));
2525
});

test/stopwatch_test.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void main() {
2525
});
2626

2727
group('before it starts', () {
28-
Stopwatch stopwatch;
28+
late Stopwatch stopwatch;
2929
setUp(() {
3030
stopwatch = clock.stopwatch();
3131
});
@@ -47,9 +47,9 @@ void main() {
4747
});
4848

4949
group('when 12345μs have elapsed', () {
50-
DateTime time;
51-
Clock clock;
52-
Stopwatch stopwatch;
50+
late DateTime time;
51+
late Clock clock;
52+
late Stopwatch stopwatch;
5353
setUp(() {
5454
time = date(1990, 11, 8);
5555
clock = Clock(() => time);

test/utils.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import 'package:clock/clock.dart';
1616

1717
/// A utility function for tersely constructing a [DateTime] with no time
1818
/// component.
19-
DateTime date(int year, [int month, int day]) =>
19+
DateTime date(int year, [int? month, int? day]) =>
2020
DateTime(year, month ?? 1, day ?? 1);
2121

2222
/// Returns a clock that always returns a date with the given [year], [month],
2323
/// and [day].
24-
Clock fixed(int year, [int month, int day]) =>
24+
Clock fixed(int year, [int? month, int? day]) =>
2525
Clock.fixed(date(year, month, day));

0 commit comments

Comments
 (0)