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

outdated

Alan voice plugin. One can easily add voice interaction to exisiting app with this plugin See more on the homepage and in the docs section - https://alan.app/docs

example/lib/main.dart

import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:alan_voice/alan_voice.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class AlanStartButton extends StatefulWidget {
  AlanStartButton({Key key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return new AlanButtonState();
  }
}

class AlanButtonState extends State<AlanStartButton> {
  GlobalKey globalKey = GlobalKey();
  String _platformVersion = 'Unknown';
  bool _enabled = true;

  void _initAlanButton() async {
    AlanVoice.addConnectionCallback(
        (str) => debugPrint("Connection state callback. New state is $str"));
    AlanVoice.addButton(
        "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.callProjectApi("script::test", "{\"x\":\"Hey!\"}");
      print(res);
    } on Exception catch (e) {
      print(e.toString());
    }
  }

  Future<void> _capturePng() async {
    RenderRepaintBoundary boundary =
        globalKey.currentContext.findRenderObject();
    ui.Image image = await boundary.toImage();
    ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
    Uint8List pngBytes = byteData.buffer.asUint8List();
    print(pngBytes);
  }

  void testScreenshot() {
    var version = AlanVoice.version;
    print(version);
  }

  @override
  Widget build(BuildContext context) {
    return new Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text('Running on: $_platformVersion\n'),
          RepaintBoundary(
            key: globalKey,
            child: RaisedButton(
              key: new Key("start_btn"),
              color: Colors.blueAccent,
//            onPressed: _enabled ? _initAlanButton : null,
              onPressed: testScreenshot,
              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()),
      ),
    );
  }
}
114
likes
0
points
496
downloads

Publisher

unverified uploader

Weekly Downloads

Alan voice plugin. One can easily add voice interaction to exisiting app with this plugin See more on the homepage and in the docs section - https://alan.app/docs

Homepage

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, package_info

More

Packages that depend on alan_voice