import 'package:shared_preferences/shared_preferences.dart';

class LicenseService {
  static const int freeLimit = 3;
  Future<int> usedChecks() async => (await SharedPreferences.getInstance()).getInt('checksUsed') ?? 0;
  Future<bool> isPaid() async => (await SharedPreferences.getInstance()).getBool('isPaid') ?? false;
  Future<bool> canAnalyze() async => await isPaid() || await usedChecks() < freeLimit;
  Future<bool> canExportChecklist() async => await isPaid();
  Future<void> registerCheck() async { final sp = await SharedPreferences.getInstance(); sp.setInt('checksUsed', (sp.getInt('checksUsed') ?? 0) + 1); }
  Future<void> setPaid(bool value) async => (await SharedPreferences.getInstance()).setBool('isPaid', value);
}
