elevensdk_flutter_plugin 0.1.4 copy "elevensdk_flutter_plugin: ^0.1.4" to clipboard
elevensdk_flutter_plugin: ^0.1.4 copied to clipboard

flutter plugin for the 11sight sdk

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:elevensdk_flutter_plugin/elevensdk_flutter_plugin.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  //final buttonId = "GTQgNEIygTpKXnj4aIFJ-3_MwgWYVLtEGRzmYA1D5mG5BAzsRx"; // vinay : prod

  final buttonId = "I42zw7hp1zIoN28qXdzFIJ5RAdKIVOeEJXlbyJaubuHQ8D4ivb";    // togg : prod

  final _formKey = GlobalKey<FormState>();
  String _platformVersion = 'Unknown';
  final _elevensdkFlutterPlugin = ElevensdkFlutterPlugin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await _elevensdkFlutterPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(builder: (ctx) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('11Sight Sdk with Flutter Plugin'),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Padding(
                  padding: const EdgeInsets.only(top: 16),
                  child: Text('Running on: $_platformVersion\n'),
                ),
                Form(
                    key: _formKey,
                    child: Padding(
                      padding: const EdgeInsets.all(16.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          TextFormField(
                            initialValue: buttonId,
                            validator: (value) {
                              if (value == null || value.isEmpty) {
                                return 'Enter yours button ID';
                              }
                              return null;
                            },
                          ),
                          const SizedBox(height: 24),
                          ElevatedButton(
                            onPressed: () {
                              if (_formKey.currentState!.validate()) {
                                onPressed(buttonId);
                              }
                            },
                            child: const Text('Start Call'),
                          )
                        ],
                      ),
                    )),
              ],
            ),
          ),
        );
      }),
    );
  }

  Future<Null> onPressed(String buttonId) async {
    try {
      await _elevensdkFlutterPlugin.makeCall(buttonId);
    } on PlatformException {
      debugPrintStack();
    }
  }
}
0
likes
130
points
123
downloads

Publisher

unverified uploader

Weekly Downloads

flutter plugin for the 11sight sdk

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on elevensdk_flutter_plugin