vihaya_sdk_flutter 0.1.1 copy "vihaya_sdk_flutter: ^0.1.1" to clipboard
vihaya_sdk_flutter: ^0.1.1 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.

example/main.dart

// ignore_for_file: avoid_print

import 'package:vihaya_sdk_flutter/vihaya_sdk_flutter.dart';

void main() async {
  // 1. Initialize the client
  final client = VihayaClient('YOUR_API_KEY');

  try {
    // 2. Fetch list of events
    print('Fetching events...');
    final events = await client.events.list();
    print('Found ${events.length} events.');

    for (var event in events) {
      print('--- ${event.title} ---');
      print('ID: ${event.id}');
      print('Price: ${event.isFree ? "Free" : event.price}');
      print('Location: ${event.location}');
    }

    if (events.isNotEmpty) {
      final firstEventId = events.first.id;

      // 3. Get detailed info for the first event
      print('\nFetching details for event: $firstEventId');
      final eventDetails = await client.events.get(firstEventId);
      print('Description: ${eventDetails.description}');

      // 4. Register for the event
      print('\nRegistering for event...');
      final registration = RegisterData(
        name: 'Vihaya User',
        email: 'user@vihaya.app',
        phone: '8590836158',
        customFields: {'Collge': 'Vihaya Institute'},
      );

      final response = await client.events.register(firstEventId, registration);

      if (response['success'] == true) {
        if (response['isPaid'] == true) {
          print(
            'Registration pending payment. Order ID: ${response['orderId']}',
          );

          // 5. Verify payment (Example context)
          // In a real app, you'd get these after the Razorpay flow
          /*
          await client.payments.verify(
            paymentId: 'pay_ABC123',
            orderId: response['orderId'],
            signature: 'xyz789...',
          );
          print('Payment verified successfully!');
          */
        } else {
          print(
            'Registration successful! Registration ID: ${response['registrationId']}',
          );
        }
      }
    }
  } on VihayaException catch (e) {
    print('API Error: ${e.message} (Status: ${e.status})');
  } catch (e) {
    print('Unexpected error: $e');
  }
}
0
likes
150
points
114
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Official Flutter SDK for the Vihaya Events platform. Fetch events, register attendees, handle custom fields, and verify Razorpay payments with a fully-typed client.

Homepage
Repository (GitHub)
View/report issues

Topics

#vihaya #events #ticketing #razorpay #sdk

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on vihaya_sdk_flutter