Skip to content

Commit c488533

Browse files
authored
Merge pull request #1 from CillianMyles/null-safety
Null Safety
2 parents 7381d54 + edd06ac commit c488533

15 files changed

+213
-136
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.9.0-nullsafety.0] - 2021/03/07
2+
3+
* Migrate library to use sound null safety
4+
15
## [0.0.3] - 2021/02/13
26

37
* Initial release v3 (better description => improved pub.dev score)

README.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
# TapCanvas
1+
# 🚰 TapCanvas
22

33
Detect taps outside the currently defined widget and provide a callback when taps occur.
44

5-
## Example
5+
## Example
66

77
```dart
88
void main() {
99
runApp(const MyApp());
1010
}
1111
1212
class MyApp extends StatelessWidget {
13-
const MyApp({Key key}) : super(key: key);
13+
const MyApp({Key? key}) : super(key: key);
1414
1515
@override
16-
Widget build(BuildContext context) => MaterialApp(
16+
Widget build(BuildContext context) =>
17+
MaterialApp(
1718
title: 'Tap Canvas Demo',
1819
theme: ThemeData(
1920
primarySwatch: Colors.grey,
@@ -27,7 +28,7 @@ class MyApp extends StatelessWidget {
2728
}
2829
2930
class DemoPage extends StatefulWidget {
30-
const DemoPage({Key key}) : super(key: key);
31+
const DemoPage({Key? key}) : super(key: key);
3132
3233
@override
3334
DemoPageState createState() => DemoPageState();
@@ -56,7 +57,8 @@ class DemoPageState extends State<DemoPage> {
5657
}
5758
5859
@override
59-
Widget build(BuildContext context) => TapCanvas(
60+
Widget build(BuildContext context) =>
61+
TapCanvas(
6062
child: Row(
6163
children: [
6264
Container(
@@ -108,16 +110,3 @@ class DemoPageState extends State<DemoPage> {
108110
);
109111
}
110112
```
111-
112-
## TODOs
113-
114-
- [ ] Create better demo app to show off use case
115-
- [x] Add documentation for public classes / methods
116-
- [x] Add test coverage
117-
- [ ] Add more convenience widgets e.g. `TapOutsideDismissFocusWidget`
118-
- [x] Example to README
119-
- [x] Install guide (handled by pub.dev)
120-
- [ ] Screenshots / GIF of demo
121-
- [ ] Automate tests
122-
- [ ] Display code coverage % badge
123-
- [x] Upload to pub.dev

example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main() {
66
}
77

88
class MyApp extends StatelessWidget {
9-
const MyApp({Key key}) : super(key: key);
9+
const MyApp({Key? key}) : super(key: key);
1010

1111
@override
1212
Widget build(BuildContext context) => MaterialApp(
@@ -23,7 +23,7 @@ class MyApp extends StatelessWidget {
2323
}
2424

2525
class DemoPage extends StatefulWidget {
26-
const DemoPage({Key key}) : super(key: key);
26+
const DemoPage({Key? key}) : super(key: key);
2727

2828
@override
2929
DemoPageState createState() => DemoPageState();

example/pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
name: characters
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "1.1.0-nullsafety.5"
10+
version: "1.1.0"
1111
collection:
1212
dependency: transitive
1313
description:
1414
name: collection
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.15.0-nullsafety.5"
17+
version: "1.15.0"
1818
cupertino_icons:
1919
dependency: "direct main"
2020
description:
@@ -33,7 +33,7 @@ packages:
3333
name: meta
3434
url: "https://pub.dartlang.org"
3535
source: hosted
36-
version: "1.3.0-nullsafety.6"
36+
version: "1.3.0"
3737
sky_engine:
3838
dependency: transitive
3939
description: flutter
@@ -52,14 +52,14 @@ packages:
5252
name: typed_data
5353
url: "https://pub.dartlang.org"
5454
source: hosted
55-
version: "1.3.0-nullsafety.5"
55+
version: "1.3.0"
5656
vector_math:
5757
dependency: transitive
5858
description:
5959
name: vector_math
6060
url: "https://pub.dartlang.org"
6161
source: hosted
62-
version: "2.1.0-nullsafety.5"
62+
version: "2.1.0"
6363
sdks:
64-
dart: ">=2.12.0-0 <3.0.0"
64+
dart: ">=2.12.0 <3.0.0"
6565
flutter: ">=1.17.0"

example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ publish_to: 'none'
44
version: 1.0.0+1
55

66
environment:
7-
sdk: ">=2.7.0 <3.0.0"
7+
sdk: ">=2.12.0 <3.0.0"
88

99
dependencies:
10-
cupertino_icons: "^1.0.2"
10+
cupertino_icons: ^1.0.2
1111
flutter:
1212
sdk: flutter
1313
tap_canvas:

lib/src/tap_canvas.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import 'package:tap_canvas/src/tap_outside_detector_widget.dart';
1212
/// such that it could lower the area of "taps outside" tracking.
1313
class TapCanvas extends StatefulWidget {
1414
const TapCanvas({
15-
@required this.child,
16-
Key key,
17-
}) : assert(child != null),
18-
super(key: key);
15+
required this.child,
16+
Key? key,
17+
}) : super(key: key);
1918

2019
final Widget child;
2120

lib/src/tap_offset_provider.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ import 'package:tap_canvas/src/tap_canvas.dart';
1010
@immutable
1111
class TapOffsetProvider extends InheritedWidget {
1212
const TapOffsetProvider({
13-
@required this.stream,
14-
@required Widget child,
15-
Key key,
16-
}) : assert(stream != null),
17-
assert(child != null),
18-
super(key: key, child: child);
13+
required this.stream,
14+
required Widget child,
15+
Key? key,
16+
}) : super(key: key, child: child);
1917

2018
final Stream<Offset> stream;
2119

22-
static TapOffsetProvider of(BuildContext context) =>
20+
static TapOffsetProvider? of(BuildContext context) =>
2321
context.dependOnInheritedWidgetOfExactType<TapOffsetProvider>();
2422

2523
@override

lib/src/tap_outside_detector_widget.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@ import 'package:tap_canvas/src/tap_offset_provider.dart';
1111
/// focus and text input when something outside of it is interacted with.
1212
class TapOutsideDetectorWidget extends StatefulWidget {
1313
const TapOutsideDetectorWidget({
14-
@required this.child,
15-
@required this.onTappedOutside,
14+
required this.child,
15+
required this.onTappedOutside,
1616
this.onTappedInside,
17-
Key key,
18-
}) : assert(child != null),
19-
assert(onTappedOutside != null),
20-
super(key: key);
17+
Key? key,
18+
}) : super(key: key);
2119

2220
final Widget child;
2321
final VoidCallback onTappedOutside;
24-
final VoidCallback onTappedInside;
22+
final VoidCallback? onTappedInside;
2523

2624
@override
2725
_TapOutsideDetectorWidgetState createState() =>
2826
_TapOutsideDetectorWidgetState();
2927
}
3028

3129
class _TapOutsideDetectorWidgetState extends State<TapOutsideDetectorWidget> {
32-
StreamSubscription<Offset> _tapOffsetSubscription;
30+
StreamSubscription<Offset>? _tapOffsetSubscription;
3331

3432
@override
3533
void dispose() {
@@ -41,7 +39,7 @@ class _TapOutsideDetectorWidgetState extends State<TapOutsideDetectorWidget> {
4139
void didChangeDependencies() {
4240
super.didChangeDependencies();
4341
_tapOffsetSubscription ??=
44-
TapOffsetProvider?.of(context)?.stream?.listen(_handleTap);
42+
TapOffsetProvider?.of(context)?.stream.listen(_handleTap);
4543
}
4644

4745
void _handleTap(Offset position) {

pubspec.lock

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.5.0-nullsafety.3"
10+
version: "2.5.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.1.0-nullsafety.3"
17+
version: "2.1.0"
1818
characters:
1919
dependency: transitive
2020
description:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0-nullsafety.5"
24+
version: "1.1.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0-nullsafety.3"
31+
version: "1.2.0"
3232
clock:
3333
dependency: transitive
3434
description:
3535
name: clock
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "1.1.0-nullsafety.3"
38+
version: "1.1.0"
3939
collection:
4040
dependency: transitive
4141
description:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0-nullsafety.5"
45+
version: "1.15.0"
4646
fake_async:
4747
dependency: transitive
4848
description:
4949
name: fake_async
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.2.0-nullsafety.3"
52+
version: "1.2.0"
5353
flutter:
5454
dependency: "direct main"
5555
description: flutter
@@ -60,27 +60,41 @@ packages:
6060
description: flutter
6161
source: sdk
6262
version: "0.0.0"
63+
flutter_test_ui:
64+
dependency: "direct dev"
65+
description:
66+
name: flutter_test_ui
67+
url: "https://pub.dartlang.org"
68+
source: hosted
69+
version: "2.0.0-nullsafety.0"
6370
matcher:
6471
dependency: transitive
6572
description:
6673
name: matcher
6774
url: "https://pub.dartlang.org"
6875
source: hosted
69-
version: "0.12.10-nullsafety.3"
76+
version: "0.12.10"
7077
meta:
7178
dependency: transitive
7279
description:
7380
name: meta
7481
url: "https://pub.dartlang.org"
7582
source: hosted
76-
version: "1.3.0-nullsafety.6"
83+
version: "1.3.0"
84+
mocktail:
85+
dependency: "direct dev"
86+
description:
87+
name: mocktail
88+
url: "https://pub.dartlang.org"
89+
source: hosted
90+
version: "0.0.2-dev.2"
7791
path:
7892
dependency: transitive
7993
description:
8094
name: path
8195
url: "https://pub.dartlang.org"
8296
source: hosted
83-
version: "1.8.0-nullsafety.3"
97+
version: "1.8.0"
8498
sky_engine:
8599
dependency: transitive
86100
description: flutter
@@ -92,56 +106,56 @@ packages:
92106
name: source_span
93107
url: "https://pub.dartlang.org"
94108
source: hosted
95-
version: "1.8.0-nullsafety.4"
109+
version: "1.8.0"
96110
stack_trace:
97111
dependency: transitive
98112
description:
99113
name: stack_trace
100114
url: "https://pub.dartlang.org"
101115
source: hosted
102-
version: "1.10.0-nullsafety.6"
116+
version: "1.10.0"
103117
stream_channel:
104118
dependency: transitive
105119
description:
106120
name: stream_channel
107121
url: "https://pub.dartlang.org"
108122
source: hosted
109-
version: "2.1.0-nullsafety.3"
123+
version: "2.1.0"
110124
string_scanner:
111125
dependency: transitive
112126
description:
113127
name: string_scanner
114128
url: "https://pub.dartlang.org"
115129
source: hosted
116-
version: "1.1.0-nullsafety.3"
130+
version: "1.1.0"
117131
term_glyph:
118132
dependency: transitive
119133
description:
120134
name: term_glyph
121135
url: "https://pub.dartlang.org"
122136
source: hosted
123-
version: "1.2.0-nullsafety.3"
137+
version: "1.2.0"
124138
test_api:
125139
dependency: transitive
126140
description:
127141
name: test_api
128142
url: "https://pub.dartlang.org"
129143
source: hosted
130-
version: "0.2.19-nullsafety.6"
144+
version: "0.2.19"
131145
typed_data:
132146
dependency: transitive
133147
description:
134148
name: typed_data
135149
url: "https://pub.dartlang.org"
136150
source: hosted
137-
version: "1.3.0-nullsafety.5"
151+
version: "1.3.0"
138152
vector_math:
139153
dependency: transitive
140154
description:
141155
name: vector_math
142156
url: "https://pub.dartlang.org"
143157
source: hosted
144-
version: "2.1.0-nullsafety.5"
158+
version: "2.1.0"
145159
sdks:
146-
dart: ">=2.12.0-0.0 <3.0.0"
160+
dart: ">=2.12.0 <3.0.0"
147161
flutter: ">=1.17.0"

0 commit comments

Comments
 (0)