Skip to content

Commit

Permalink
refacto: replaced FutureOr with Future
Browse files Browse the repository at this point in the history
  • Loading branch information
TesteurManiak committed May 25, 2023
1 parent 4bab27d commit 3ec28b9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/src/matomo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class MatomoTracker {
}

/// Iterate on the actions in the queue and send them to Matomo.
FutureOr<void> dispatchActions() {
Future<void> dispatchActions() {
return _dequeue();
}

Expand Down Expand Up @@ -716,7 +716,7 @@ class MatomoTracker {
}
}

FutureOr<void> _dequeue() {
Future<void> _dequeue() async {
if (!_initialized) {
throw const UninitializedMatomoInstanceException();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/lock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Lock {
bool get locked => last != null;

Future<T> synchronized<T>(
FutureOr<T> Function() func,
Future<T> Function() func,
) async {
final prev = last;
final completer = Completer<void>.sync();
Expand Down
6 changes: 2 additions & 4 deletions test/ressources/utils/uninitialized_test_util.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'dart:async';

import 'package:flutter_test/flutter_test.dart';
import 'package:matomo_tracker/src/exceptions.dart';
import 'package:matomo_tracker/src/matomo.dart';
import 'package:meta/meta.dart';

typedef TrackerCallback = FutureOr<void> Function(MatomoTracker tracker);
typedef TrackerCallback = Future<void> Function(MatomoTracker tracker);

/// A test that expects the [callback] to throw an
/// [UninitializedMatomoInstanceException].
Expand All @@ -17,7 +15,7 @@ void uninitializedTest(TrackerCallback callback) {
final matomoTracker = MatomoTracker();

await expectLater(
() async => await callback(matomoTracker),
() async => callback(matomoTracker),
throwsA(isA<UninitializedMatomoInstanceException>()),
);
},
Expand Down
4 changes: 2 additions & 2 deletions test/src/matomo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void main() {

group('trackScreenWithName', () {
uninitializedTest(
(tracker) {
(tracker) async {
tracker.trackScreenWithName(
actionName: matomoTrackerMockWidget.toStringShort(),
);
Expand Down Expand Up @@ -268,7 +268,7 @@ void main() {
});

group('setVisitorUserId', () {
uninitializedTest((tracker) => tracker.setVisitorUserId(uid));
uninitializedTest((tracker) async => tracker.setVisitorUserId(uid));

test('it should be able to set visitor userId', () async {
final matomoTracker = await getInitializedMatomoTracker();
Expand Down

0 comments on commit 3ec28b9

Please sign in to comment.