Skip to content

Commit

Permalink
Add more linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Jan 24, 2023
1 parent 40f1b67 commit e7bae6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 9 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ analyzer:
strict-casts: true
strict-inference: true
strict-raw-types: true
exclude:
- lib/generated_plugin_registrant.dart

linter:
rules:
Expand All @@ -18,6 +16,7 @@ linter:
avoid_final_parameters: true
avoid_implementing_value_types: true
avoid_js_rounded_ints: true
avoid_multiple_declarations_per_line: true
avoid_positional_boolean_parameters: true
avoid_returning_this: true
avoid_setters_without_getters: true
Expand All @@ -28,10 +27,13 @@ linter:
cancel_subscriptions: true
cast_nullable_to_non_nullable: true
close_sinks: true
combinators_ordering: true
comment_references: true
conditional_uri_does_not_exist: true
directives_ordering: true
discarded_futures: true
flutter_style_todos: true
invariant_booleans: true
join_return_with_assignment: true
no_adjacent_strings_in_list: true
omit_local_variable_types: true
Expand All @@ -53,14 +55,19 @@ linter:
throw_in_finally: true
tighten_type_of_initializing_formals: true
unawaited_futures: true
unnecessary_await_in_return: false
unnecessary_lambdas: true
unnecessary_null_aware_operator_on_extension_on_nullable: true
unnecessary_parenthesis: true
unnecessary_statements: true
unnecessary_to_list_in_spreads: true
unreachable_from_main: true
unsafe_html: true
use_colored_box: true
use_decorated_box: true
use_enums: true
use_key_in_widget_constructors: false
use_setters_to_change_properties: true
use_string_buffers: true
use_string_in_part_of_directives: true
use_super_parameters: true
18 changes: 11 additions & 7 deletions lib/src/components/now_indicator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:ui';

import 'package:async/async.dart';
Expand Down Expand Up @@ -314,7 +315,7 @@ class _NowIndicatorPainter extends CustomPainter {

@override
void paint(Canvas canvas, Size size) {
_repaint?.cancel();
unawaited(_repaint?.cancel());
_repaint = null;

final pageValue = controller.value;
Expand All @@ -340,11 +341,14 @@ class _NowIndicatorPainter extends CustomPainter {
final maxDistance = 0.5 / devicePixelRatio;
final delay = 1.days * (maxDistance / size.height);
_repaint = CancelableOperation.fromFuture(
Future<void>.delayed(delay).then((_) {
// [ChangeNotifier.notifyListeners] is protected, so we use a
// [ValueNotifier] and always set a different time.
_repaintNotifier.value = DateTimeTimetable.now();
}),
Future<void>.delayed(
delay,
() {
// [ChangeNotifier.notifyListeners] is protected, so we use a
// [ValueNotifier] and always set a different time.
_repaintNotifier.value = DateTimeTimetable.now();
},
),
);
}

Expand All @@ -362,7 +366,7 @@ class _NowIndicatorPainter extends CustomPainter {
void removeListener(VoidCallback listener) {
_activeListenerCount--;
if (_activeListenerCount == 0) {
_repaint?.cancel();
unawaited(_repaint?.cancel());
_repaint = null;
}
super.removeListener(listener);
Expand Down

0 comments on commit e7bae6d

Please sign in to comment.