ponshu-room-lite/lib/providers/license_provider.dart

20 lines
745 B
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../services/license_service.dart';
/// ライセンス状態の非同期プロバイダー
///
/// アプリ起動時に一度だけVPSに問い合わせ、結果をキャッシュする。
/// 手動更新は [licenseStatusProvider].invalidate() を呼ぶ。
final licenseStatusProvider = FutureProvider<LicenseStatus>((ref) async {
return LicenseService.checkStatus();
});
/// Pro版かどうかナビゲーション・機能解放の分岐に使う
final isProProvider = Provider<bool>((ref) {
final statusAsync = ref.watch(licenseStatusProvider);
return statusAsync.maybeWhen(
data: (status) => status == LicenseStatus.pro,
orElse: () => false,
);
});