cec4c3e427
Adds an in-app review prompt gated by ReviewPromptPolicy: only after a 3-star stage win, once the player has cleared >=5 stages, at most once ever (persisted reviewRequested flag). ReviewService swallows all failures and only burns the one-shot when the store actually shows the sheet, so an unavailable store retries on a later win. StoreReviewer wraps in_app_review behind a Reviewer seam so unit tests skip platform channels. 13 new tests; full suite 194 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
22 lines
727 B
Dart
22 lines
727 B
Dart
// lib/services/store_reviewer.dart
|
|
import 'package:in_app_review/in_app_review.dart';
|
|
|
|
import 'review_service.dart';
|
|
|
|
/// Production [Reviewer] that forwards to the in_app_review plugin's native
|
|
/// "rate this app" sheet (SKStoreReviewController on iOS, In-App Review API on
|
|
/// Android). Kept in its own file so [ReviewService] and its tests stay free of
|
|
/// the platform-channel dependency.
|
|
class StoreReviewer implements Reviewer {
|
|
StoreReviewer([InAppReview? inAppReview])
|
|
: _inAppReview = inAppReview ?? InAppReview.instance;
|
|
|
|
final InAppReview _inAppReview;
|
|
|
|
@override
|
|
Future<bool> isAvailable() => _inAppReview.isAvailable();
|
|
|
|
@override
|
|
Future<void> requestReview() => _inAppReview.requestReview();
|
|
}
|