vihaya_sdk_flutter 0.1.0
vihaya_sdk_flutter: ^0.1.0 copied to clipboard
Official Flutter SDK for the Vihaya Events platform. Fetch events, register attendees, handle custom fields, and verify Razorpay payments with a fully-typed client.
Vihaya Flutter SDK #
The official Flutter SDK for the Vihaya Events platform. Build attendee-facing mobile experiences with a tiny, fully-typed client.
Features #
- List events and fetch full event metadata (agenda, speakers, sponsors, FAQs).
- Register attendees with custom fields, special pricing tiers, and team support.
- Verify Razorpay payments server-side.
- Full type safety across events, registrations, and pricing.
Install #
dependencies:
vihaya_sdk_flutter: ^0.1.0
Then:
flutter pub get
Quick start #
Initialize the client #
import 'package:vihaya_sdk_flutter/vihaya_sdk_flutter.dart';
final client = VihayaClient('YOUR_API_KEY');
// Or with custom configuration:
final customClient = VihayaClient(VihayaConfig(
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://events.vihaya.app',
));
Get your API key from the Vihaya Developer Dashboard.
List events #
try {
final events = await client.events.list();
for (final event in events) {
print('${event.title} — ${event.location}');
}
} on VihayaException catch (e) {
print('Error: ${e.message} (status ${e.status})');
}
Fetch full event details #
events.get() returns everything you need to render a rich event page or
build a custom registration form — speakers, agenda, sponsors, FAQs, custom
fields, and pricing tiers.
final event = await client.events.get('event-id');
print('Title: ${event.title}');
print('Mode: ${event.eventMode}');
print('Timezone: ${event.timezone}');
// Render speakers
event.speakerList?.forEach((s) => print('- ${s.name} (${s.role})'));
// Render agenda
event.agendaList?.forEach((a) => print('[${a.time}] ${a.title}'));
Mega events (parent events with sub-events) #
If event.eventType == 'megaEvent', the event contains subEvents, each with
its own pricing and custom fields.
if (event.eventType == 'megaEvent') {
event.subEvents?.forEach((sub) {
print('- ${sub.title} (${sub.isFree ? "Free" : "₹${sub.price}"})');
});
}
Register an attendee #
final registration = RegisterData(
name: 'Anjali Mehta',
email: 'anjali@example.com',
phone: '+919820012345',
customFields: {
'T-Shirt Size': 'L',
'College': 'Vihaya Institute',
},
);
final response = await client.events.register('event-id', registration);
if (response['isPaid'] == true) {
final orderId = response['orderId'];
// Launch Razorpay checkout with this orderId, then:
await client.payments.verify(
paymentId: 'pay_xxx',
orderId: orderId,
signature: 'sig_xxx',
);
} else {
print('Registered! ID: ${response['registrationId']}');
}
Verify a payment (server-side) #
await client.payments.verify(
paymentId: 'pay_xxx',
orderId: 'order_xxx',
signature: 'sig_xxx',
);
Security: never hard-code your live secret key in a client build. Ship a restricted public key to the app and keep the secret on your backend.
Error handling #
All API failures raise VihayaException:
try {
await client.events.get('invalid-id');
} on VihayaException catch (e) {
print('Message: ${e.message}');
print('Status: ${e.status}');
print('Body: ${e.data}');
}
API reference #
client.events #
| Method | Description |
|---|---|
list() |
Returns all events on the authenticated account. |
get(id) |
Returns full metadata for one event including tiers, fields, agenda, speakers, sponsors, FAQs. |
register(id, data) |
Submits a registration. Returns orderId for paid events. |
client.payments #
| Method | Description |
|---|---|
verify(paymentId, orderId, signature) |
Server-side Razorpay signature verification. |
License #
MIT — see LICENSE.