alan_voice 0.6.0 copy "alan_voice: ^0.6.0" to clipboard
alan_voice: ^0.6.0 copied to clipboard

outdated

Alan voice plugin

example/lib/main.dart

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()
        ),
      ),
    );
  }

}
107
likes
0
pub points
87%
popularity

Publisher

unverified uploader

Alan voice plugin

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on alan_voice