alan_voice 0.6.1 alan_voice: ^0.6.1 copied to clipboard
Alan voice plugin
import 'package:alan_voice/alan_voice.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class AlanStartButton extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new AlanButtonState();
}
}
class AlanButtonState extends State<AlanStartButton> {
String _platformVersion = 'Unknown';
bool _enabled = true;
void _initAlanButton() async {
AlanVoice.initButton("8e0b083e795c924d64635bba9c3571f42e956eca572e1d8b807a3e2338fdd0dc/stage");
String platformVersion;
try {
platformVersion = await AlanVoice.version;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
_testCall();
setState(() {
_platformVersion = platformVersion;
_enabled = false;
});
}
void _testCall() async {
try {
var res = await AlanVoice.call("script::test", "{\"x\":\"Hey!\"}");
print (res);
} on Exception catch (e){
print(e.toString());
}
}
@override
Widget build(BuildContext context) {
return new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Running on: $_platformVersion\n'),
RaisedButton(
key: new Key("start_btn"),
color: Colors.blueAccent,
onPressed: _enabled ? _initAlanButton : null,
textColor: Colors.white,
child: const Text("START"),
),
]);
}
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Alan voice plugin example'),
),
body: Center(
child: new AlanStartButton()
),
),
);
}
}