teller_connect_flutter 0.12.1 copy "teller_connect_flutter: ^0.12.1" to clipboard
teller_connect_flutter: ^0.12.1 copied to clipboard

A Flutter plugin for integrating the Teller Connect SDK, allowing seamless connection to financial institutions and access to financial data.

example/lib/main.dart

import 'dart:async';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:teller_connect_flutter/teller_connect_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // 1. Initialize the SDK
  TellerConnectFlutter.initialize(
    appId: 'app_ough6na3p9ve6id794000',
    certFile:
        (await rootBundle.load('assets/certificate.pem')).buffer.asUint8List(),
    keyFile:
        (await rootBundle.load('assets/private_key.pem')).buffer.asUint8List(),
  );

  runApp(
    const MyApp(),
  );
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late StreamSubscription<TellerEventModel> _subscription;
  final tokens = <String, String>{};

  @override
  void initState() {
    super.initState();
    // 2. Listen to Teller Connect events
    _subscription =
        TellerConnectFlutter.instance.onTellerEvent.listen(_handleTellerEvent);
  }

  void _handleTellerEvent(TellerEventModel event) async {
    if (event is InitEvent) {
      log('Teller Connect initialized');
    } else if (event is RegisterSuccessEvent) {
      log('Registration successful: ${event.accessToken}');
      // Handle successful registration
      final accounts = await TellerConnectFlutter.instance
          .getConnectedAccounts(event.enrollmentId);
      log('Connected accounts: $accounts');

      final accountId = accounts.first.id;
      final accountDetails = await TellerConnectFlutter.instance.getAccount(
        accountId: accountId,
        enrollmentId: event.enrollmentId,
      );
      log('Account details: $accountDetails');

      final transactions =
          await TellerConnectFlutter.instance.getAccountTransactions(
        accountId: accountId,
        enrollmentId: event.enrollmentId,
      );
      log('Transactions: $transactions');

      final transactionId = transactions.first.id;
      final transactionDetails =
          await TellerConnectFlutter.instance.getTransaction(
        transactionId: transactionId,
        accountId: accountId,
        enrollmentId: event.enrollmentId,
      );
      log('Transaction details: $transactionDetails');
    } else if (event is FailureEvent) {
      log('Error: ${event.message}');
      // Handle failure
    }
  }

  Future<void> _startTellerConnect() {
    return TellerConnectFlutter.instance.startTellerConnect(
      saveToken: (token, enrollmentId) async {
        setState(() {
          tokens[enrollmentId] = token;
        });
      },
      getToken: (enrollmentId) => Future.value(
        tokens[enrollmentId]!,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Teller Connect Example'),
        ),
        body: Center(
          child: FutureBuilder<void>(
            future: _startTellerConnect(),
            builder: (context, snapshot) {
              if (snapshot.connectionState == ConnectionState.waiting) {
                return const CircularProgressIndicator();
              } else if (snapshot.hasError) {
                return Text('Error: ${snapshot.error}');
              }
              return ElevatedButton(
                onPressed: () {
                  setState(() {});
                }, // 3. Start Teller Connect
                child: const Text('Start Teller Connect'),
              );
            },
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _subscription.cancel();
    super.dispose();
  }
}
0
likes
130
points
81
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating the Teller Connect SDK, allowing seamless connection to financial institutions and access to financial data.

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter, freezed_annotation, json_annotation, plugin_platform_interface

More

Packages that depend on teller_connect_flutter

Packages that implement teller_connect_flutter