authic_app_sdk 1.0.0+2 authic_app_sdk: ^1.0.0+2 copied to clipboard
Official SDK to integrate Authic's perks platform.
import 'package:flutter/material.dart';
import 'package:authic_app_sdk/authic_app_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Home(),
);
}
}
final _authicAppSdkPlugin = AuthicAppSdk(
tenantId: "41232ebe-9e09-4069-9010-cd553b2cedb3",
environment: Environment.sandbox,
);
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
AuthicMembership? membership;
List<AuthicQuest>? quests;
String? email, referralCode;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
actions: [
if (_authicAppSdkPlugin.currentUser != null)
IconButton(
onPressed: () async {
await _authicAppSdkPlugin.logout();
setState(() {
email = null;
referralCode = null;
});
},
icon: const Icon(Icons.logout),
),
],
),
body: Column(
children: [
if (email == null)
Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
TextField(
onChanged: (value) {
email = value;
},
decoration: const InputDecoration(
hintText: "Enter email",
),
),
const SizedBox(height: 10),
TextField(
onChanged: (value) {
if (value.trim().isEmpty) {
referralCode = null;
} else {
referralCode = value;
}
},
decoration: const InputDecoration(
hintText: "Referral code",
),
),
const SizedBox(height: 10),
OutlinedButton(
onPressed: () async {
await _authicAppSdkPlugin.authenticate(
email: email!,
referralCode: referralCode,
);
setState(() {});
},
child: const Text("Authenticate"),
),
],
),
)
else ...[
AuthicPoints(
sdk: _authicAppSdkPlugin,
),
AuthicQuests(
sdk: _authicAppSdkPlugin,
),
]
],
),
);
}
}