Skip to content

Commit 06e326e

Browse files
Merge pull request #290 from juliuscanute/stable-null-safety
stable version of null-safety
2 parents 9e43943 + ec0b807 commit 06e326e

12 files changed

Lines changed: 96 additions & 255 deletions

.github/workflows/dart.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v1
12-
- uses: actions/setup-java@v1
13-
with:
14-
java-version: '12.x'
15-
- uses: subosito/flutter-action@v1
16-
with:
17-
channel: 'stable'
18-
- name: Version
19-
run: flutter doctor -v
20-
- name: Install dependencies
21-
run: flutter pub get
22-
- name: Format
23-
run: dartfmt -n --set-exit-if-changed .
24-
- name: Linter
25-
run: dartanalyzer . --options=analysis_options.yaml --fatal-hints
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-java@v1
13+
with:
14+
java-version: '12.x'
15+
- uses: subosito/flutter-action@v1
16+
- name: Version
17+
run: flutter doctor -v
18+
- name: Install dependencies
19+
run: flutter pub get
20+
- name: Format
21+
run: flutter format -n --set-exit-if-changed .
22+
- name: Linter
23+
run: flutter analyze

analysis_options.yaml

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1 @@
1-
include: package:pedantic/analysis_options.yaml
2-
3-
linter:
4-
rules:
5-
- always_put_required_named_parameters_first
6-
- always_require_non_null_named_parameters
7-
- avoid_annotating_with_dynamic
8-
- avoid_bool_literals_in_conditional_expressions
9-
- avoid_catching_errors
10-
- avoid_classes_with_only_static_members
11-
- avoid_empty_else
12-
- avoid_init_to_null
13-
- avoid_null_checks_in_equality_operators
14-
- avoid_print
15-
- avoid_relative_lib_imports
16-
- avoid_return_types_on_setters
17-
- avoid_returning_null
18-
- avoid_returning_null_for_future
19-
- avoid_returning_null_for_void
20-
- avoid_shadowing_type_parameters
21-
- avoid_single_cascade_in_expression_statements
22-
- avoid_types_as_parameter_names
23-
- avoid_types_on_closure_parameters
24-
- avoid_void_async
25-
- await_only_futures
26-
- camel_case_types
27-
- cancel_subscriptions
28-
- cascade_invocations
29-
- close_sinks
30-
- comment_references
31-
- constant_identifier_names
32-
- control_flow_in_finally
33-
- curly_braces_in_flow_control_structures
34-
- directives_ordering
35-
- empty_catches
36-
- empty_constructor_bodies
37-
- empty_statements
38-
- file_names
39-
- hash_and_equals
40-
- implementation_imports
41-
- invariant_booleans
42-
- iterable_contains_unrelated_type
43-
- join_return_with_assignment
44-
- library_names
45-
- library_prefixes
46-
- list_remove_unrelated_type
47-
- no_duplicate_case_values
48-
- non_constant_identifier_names
49-
- null_closures
50-
- only_throw_errors
51-
- overridden_fields
52-
- package_api_docs
53-
- package_names
54-
- package_prefixed_library_names
55-
- prefer_collection_literals
56-
- prefer_conditional_assignment
57-
- prefer_const_declarations
58-
- prefer_contains
59-
- prefer_equal_for_default_values
60-
- prefer_final_fields
61-
- prefer_for_elements_to_map_fromIterable
62-
- prefer_foreach
63-
- prefer_function_declarations_over_variables
64-
- prefer_if_elements_to_conditional_expressions
65-
- prefer_if_null_operators
66-
- prefer_initializing_formals
67-
- prefer_inlined_adds
68-
- prefer_int_literals
69-
- prefer_interpolation_to_compose_strings
70-
- prefer_is_empty
71-
- prefer_is_not_empty
72-
- prefer_iterable_whereType
73-
- prefer_null_aware_operators
74-
- prefer_void_to_null
75-
- provide_deprecation_message
76-
- recursive_getters
77-
- slash_for_doc_comments
78-
- sort_child_properties_last
79-
- sort_constructors_first
80-
- sort_pub_dependencies
81-
- sort_unnamed_constructors_first
82-
- test_types_in_equals
83-
- throw_in_finally
84-
- type_init_formals
85-
- unawaited_futures
86-
- unnecessary_await_in_return
87-
- unnecessary_brace_in_string_interps
88-
- unnecessary_const
89-
- unnecessary_getters_setters
90-
- unnecessary_lambdas
91-
- unnecessary_new
92-
- unnecessary_null_aware_assignments
93-
- unnecessary_null_in_if_null_operators
94-
- unnecessary_overrides
95-
- unnecessary_parenthesis
96-
- unnecessary_statements
97-
- unnecessary_this
98-
- unrelated_type_equality_checks
99-
- unsafe_html
100-
- use_full_hex_values_for_flutter_colors
101-
- use_function_type_syntax_for_parameters
102-
- use_rethrow_when_possible
103-
- use_setters_to_change_properties
104-
- use_string_buffers
105-
- use_to_and_as_if_applicable
106-
- valid_regexps
107-
- void_checks
1+
include: package:pedantic/analysis_options.yaml

example/lib/main.dart

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';
77
void main() => runApp(MaterialApp(home: QRViewExample()));
88

99
class QRViewExample extends StatefulWidget {
10-
const QRViewExample({
11-
Key key,
12-
}) : super(key: key);
13-
1410
@override
1511
State<StatefulWidget> createState() => _QRViewExampleState();
1612
}
1713

1814
class _QRViewExampleState extends State<QRViewExample> {
19-
Barcode result;
20-
QRViewController controller;
15+
Barcode? result;
16+
QRViewController? controller;
2117
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
2218

2319
// In order to get hot reload to work we need to pause the camera if the platform
@@ -26,9 +22,9 @@ class _QRViewExampleState extends State<QRViewExample> {
2622
void reassemble() {
2723
super.reassemble();
2824
if (Platform.isAndroid) {
29-
controller.pauseCamera();
25+
controller!.pauseCamera();
3026
}
31-
controller.resumeCamera();
27+
controller!.resumeCamera();
3228
}
3329

3430
@override
@@ -46,7 +42,7 @@ class _QRViewExampleState extends State<QRViewExample> {
4642
children: <Widget>[
4743
if (result != null)
4844
Text(
49-
'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}')
45+
'Barcode Type: ${describeEnum(result!.format)} Data: ${result!.code}')
5046
else
5147
Text('Scan a code'),
5248
Row(
@@ -79,7 +75,7 @@ class _QRViewExampleState extends State<QRViewExample> {
7975
builder: (context, snapshot) {
8076
if (snapshot.data != null) {
8177
return Text(
82-
'Camera facing ${describeEnum(snapshot.data)}');
78+
'Camera facing ${describeEnum(snapshot.data!)}');
8379
} else {
8480
return Text('loading');
8581
}

example/pubspec.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ description: Demonstrates how to use the flutter_qr plugin.
33
publish_to: 'none'
44

55
environment:
6-
sdk: ">=2.6.0 <3.0.0"
6+
sdk: '>=2.12.0 <3.0.0'
77

88
dependencies:
99
flutter:
1010
sdk: flutter
1111

12-
# The following adds the Cupertino Icons font to your application.
13-
# Use with the CupertinoIcons class for iOS style icons.
14-
cupertino_icons: ^0.1.2
15-
1612
dev_dependencies:
13+
pedantic: ^1.11.0
1714
flutter_test:
1815
sdk: flutter
1916

lib/src/lifecycle_event_handler.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,20 @@ import 'package:flutter/foundation.dart';
33

44
class LifecycleEventHandler extends WidgetsBindingObserver {
55
LifecycleEventHandler({
6-
this.resumeCallBack,
7-
this.suspendingCallBack,
6+
required this.resumeCallBack,
87
});
98

10-
final AsyncCallback resumeCallBack;
11-
final AsyncCallback suspendingCallBack;
9+
late final AsyncCallback resumeCallBack;
1210

1311
@override
1412
Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
1513
switch (state) {
1614
case AppLifecycleState.resumed:
17-
if (resumeCallBack != null) {
18-
await resumeCallBack();
19-
}
15+
await resumeCallBack();
2016
break;
2117
case AppLifecycleState.inactive:
2218
case AppLifecycleState.paused:
2319
case AppLifecycleState.detached:
24-
if (suspendingCallBack != null) {
25-
await suspendingCallBack();
26-
}
27-
break;
2820
}
2921
}
3022
}

0 commit comments

Comments
 (0)