A Flutter Plugin for Venixs AI Chat System

Venixs_SDK

Venixs flutter Wrapper

Features

This library implements a wrapper on Venixs Chat SDK provided by aiding communication from your customers to you.

Getting Started

Install package by adding Venixs_SDK to your pubspec.yaml file

Setup

Android

To setup this project for android follow these steps:

1. Add the following to your "gradle.properties" file:

    android.useAndroidX=true
    android.enableJetifier=true

2. Make sure to set the minSdkVersion in your "android/app/build.gradle" file to a figure more than 19 if it was previously lower than 19:

    android {
      minSdkVersion 19 # Set to 19 or higher

      ...
    }

Dart/Flutter

1. To initiate the plugin, call the plugin instance in your main.dart

    final Venixs venixSdk = Venixs.instance;

    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
          .then((_) async {
            // TODO: Fetch and put your Venixs public api key here
            await Venixs.initializeInterface(publicKey: '<PUBLIC KEY HERE>');
            runApp(const MyApp());
          },
      );
    }

    ...

2. Call the Venixs Chat View method and pass the necessary data to it

    venixSdk.initiate(
      context,
      email: 'example@email.com',
      firstName: 'John',
      lastName: 'Doe',
      onCancel: (response) => print(response),
      onError: (error) => print(error),
    ),

Usage on sample button

Just call the initiate method from your any of your favorite button widget

   ElevatedButton(
      onPressed: () => venixSdk.initiate(
          context,
          email: 'example@email.com',
          firstName: 'John',
          lastName: 'Doe',
          onCancel: (response) => print(response),
          onError: (error) => print(error),
      ),
      child: Text('Call SDK'),
   ),

Questions

Ask a question and message us at support@venixs.com

Found an issue or have a proposal?

Visit our website at https://venixs.com or message us at support@venixs.com

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add venixs_sdk

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  venixs_sdk: ^0.0.1

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:venixs_sdk/venixs_sdk.dart';

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:venixs_sdk/venixs_sdk.dart';
// import 'package:simple_fontellico_progress_dialog/simple_fontico_loading.dart';


final Venixs venixSdk = Venixs.instance;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
      .then((_) async {
    // TODO: Fetch and put your Venixs public api key here
    await Venixs.initializeInterface(publicKey: '<PUBLIC KEY HERE>' /*<Account Public Api Key Here>*/);
    runApp(const MyApp());
  },
  );
}


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

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

class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
  String _platformVersion = 'Unknown';
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    initPlatformState();

    _controller = AnimationController(
      vsync: this,
      duration: const Duration(seconds: 1),
    )..repeat();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      // platformVersion =
      //     await venixSdk.getPlatformVersion() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}


class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Venixs AI Chat Test'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () => venixSdk.initiate(
                  context,
                  email: 'example@gmail.com',
                  firstName: 'Test',
                  lastName: 'Test 1',
                  userRef: 'userGeneratedRef',
                  onCancel: (response) {
                    print(response);
                  },
                  onError: (error) => print(error),
                ),
                child: const Text('Call SDK'),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

Download details:

Author: 

Source: https://pub.dev/packages/venixs_sdk

#flutter #chat 

A Flutter Plugin for Venixs AI Chat System
1.05 GEEK