generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview_service.extensions.dart
34 lines (30 loc) · 1.43 KB
/
review_service.extensions.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'package:review_service/src/review_service/review_service.dart';
import 'package:review_service/src/review_service/review_settings.dart';
/// Extensions of [IReviewService].
extension ReviewServiceExtensions<TReviewSettings extends ReviewSettings> on ReviewService<TReviewSettings> {
/// Tracks that the application was launched.
Future<void> trackApplicationLaunched() async {
await updateReviewSettings((reviewSettings) {
return reviewSettings.firstApplicationLaunch == null
? reviewSettings.copyWith(
firstApplicationLaunch: DateTime.now(),
applicationLaunchCount: reviewSettings.applicationLaunchCount + 1,
) as TReviewSettings
: reviewSettings.copyWith(
applicationLaunchCount: reviewSettings.applicationLaunchCount + 1,
) as TReviewSettings;
});
}
/// Tracks that a primary action was completed.
Future<void> trackPrimaryActionCompleted() async {
await updateReviewSettings(
(reviewSettings) => reviewSettings.copyWith(primaryActionCompletedCount: reviewSettings.primaryActionCompletedCount + 1) as TReviewSettings,
);
}
/// Tracks that a secondary action was completed.
Future<void> trackSecondaryActionCompleted() async {
await updateReviewSettings(
(reviewSettings) => reviewSettings.copyWith(secondaryActionCompletedCount: reviewSettings.secondaryActionCompletedCount + 1) as TReviewSettings,
);
}
}