venixs_sdk 0.0.2
venixs_sdk: ^0.0.2 copied to clipboard
A flutter plugin for venixs AI chat system
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: '/*<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',
/// TODO: Make sure you have firebase_messaging implemented before setting `enableNotification` to true
),
child: const Text('Call SDK'),
),
],
),
],
),
);
}
}