hi i have a flutter app about daily horoscope and tarot cards and i'm trying to implement an subscription plan for it and i choose to use revenuecat for it but i have difficulities to find a beginner document or tutorials because i really dont understand what i gotta do and also i search internet about the error but i have 0 answers for my sitution but figured out something and did my purchase function page like this
import 'package:flutter/services.dart';
import 'package:purchases_flutter/models/offering_wrapper.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
class PurchaseFlutterAPI {
static Future init() async {
await Purchases.setLogLevel(LogLevel.debug);
}
static Future<List<Offering>> fetchOffers() async {
try {
final offerings = await Purchases.getOfferings();
final activeOffering = offerings.current;
return (activeOffering == null) ? [] : [activeOffering];
} on PlatformException catch (e) {
return [];
}
}
}
and i have subscripiton page like this
import 'package:flutter/material.dart';
import 'package:horoscope101/subs.dart';
class SubsPage extends StatefulWidget {
const SubsPage({super.key});
@override
State<SubsPage> createState() => _SubsPageState();
}
class _SubsPageState extends State<SubsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _buildAppBar(),
body: Column(
children: [
ElevatedButton(
onPressed: () {
PurchaseFlutterAPI.fetchOffers();
},
child: Center(
child: Text("Get Offers"),
))
],
),
);
}
}
AppBar _buildAppBar() {
return AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: BackButton(
color: Color(0xFF9932CC),
),
title: Text(
"Your Future Is At Your Hands",
style: TextStyle(fontSize: 18, color: Color(0xFF9932CC)),
),
centerTitle: true,
);
}
and in main.dart i have like this api key and widget initialize
final _configruation =
PurchasesConfiguration("ios_api_key")
..observerMode = false;
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Purchases.configure(_configruation);
runApp(const MyApp());
}