beam_ai_sdk 0.1.3 beam_ai_sdk: ^0.1.3 copied to clipboard
The beam_ai_sdk enables easy integration of advanced AI features like NLP, image recognition, speech processing, and ML for effortless creation of intelligent applications.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:beam_ai_sdk/beam_ai_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _beamAiSdkPlugin = BeamAiSdk();
dynamic output;
Timer? timer;
@override
void initState() {
super.initState();
}
Future<void> startBeam() async {
String platformVersion;
try {
platformVersion =
await _beamAiSdkPlugin.startBeamSdk() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
stopBeam() async {
await _beamAiSdkPlugin.stopBeamSdk();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin Example'),
),
body: Center(
child: Stack(children: [
_beamAiSdkPlugin.beamCamera(
beamId: "daIfQiR7SvBKTOThKwEq",
frameRate: 30,
window: 60.0,
updateEvery: 1) ??
SizedBox.shrink(),
Positioned(
bottom: 20,
left: 0,
right: 0,
child: Column(children: [
const SizedBox(height: 20),
Text("Output ${output ?? ""}"),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
startBeam();
},
child: const Text("Start Beam ")),
const SizedBox(height: 10),
ElevatedButton(
onPressed: () {
stopBeam();
setState(() {
timer?.cancel();
output = "";
});
},
child: const Text("Stop Beam ")),
ElevatedButton(
onPressed: () async {
timer = Timer.periodic(const Duration(seconds: 1),
(timer) async {
output = await _beamAiSdkPlugin.beamSdkOutput() ??
'Unknown platform version';
print("-------------$output");
setState(() {});
});
},
child: Text("Beam Output"))
]))
]))));
}
}