attestr_flowx_plugin 0.3.3 copy "attestr_flowx_plugin: ^0.3.3" to clipboard
attestr_flowx_plugin: ^0.3.3 copied to clipboard

discontinued
PlatformAndroidiOS

A new Flutter project.

example/lib/main.dart

import 'package:attestr_flowx_plugin/attestr_flowx_plugin.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Attestr',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Attestr Sample App'),
    );
  }
}

TextEditingController handshakeIDController = TextEditingController();
TextEditingController clientKeyController = TextEditingController();

List<DropdownMenuItem<String>> get locales{
  List<DropdownMenuItem<String>> menuItems = [
    const DropdownMenuItem(value: "en", child: Text("English")),
    const DropdownMenuItem(value: "hi", child: Text("Hindi")),
    const DropdownMenuItem(value: "ma", child: Text("Marathi")),
    const DropdownMenuItem(value: "pu", child: Text("Punjabi")),
    const DropdownMenuItem(value: "be", child: Text("Bangla")),
    const DropdownMenuItem(value: "te", child: Text("Telugu")),
    const DropdownMenuItem(value: "ta", child: Text( "Tamil")),
    const DropdownMenuItem(value: "ka", child: Text("Kannada")),
    const DropdownMenuItem(value: "ml", child: Text("Malayalam")),
    const DropdownMenuItem(value: "or", child: Text("Oria")),
    const DropdownMenuItem(value: "gu", child: Text("Gujarati")),
    const DropdownMenuItem(value: "as", child: Text("Assamese")),
  ];
  return menuItems;
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String selectedLocale = "en";
  late AttestrFlowxPlugin attestrFlowxPlugin;

  @override
  void initState() {
    super.initState();
    attestrFlowxPlugin = AttestrFlowxPlugin();
    attestrFlowxPlugin.on("FLOW_COMPLETE", _handleFlowComplete);
    attestrFlowxPlugin.on("FLOW_SKIP", _handleFlowSkip);
    attestrFlowxPlugin.on("FLOW_ERROR", _handleFlowError);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.symmetric(
                  horizontal: 20,
                  vertical: 10
              ),
              child: TextField(
                controller: handshakeIDController,
                decoration: const InputDecoration(
                    border: UnderlineInputBorder(),
                    hintText: 'Enter Handshake ID'
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(
                  horizontal: 20,
                  vertical: 10
              ),
              child: TextField(
                controller: clientKeyController,
                decoration: const InputDecoration(
                    border: UnderlineInputBorder(),
                    hintText: 'Enter Client Key'
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(
                horizontal: 10,
                vertical: 5,
              ),
              child: DropdownButton(
                value: selectedLocale,
                items: locales,
                disabledHint: const Text("Select Language"),
                onChanged: (String? locale) {
                  setState(() {
                    selectedLocale = locale!;
                  });
                },
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(
                horizontal: 10,
                vertical: 5,
              ),
              child: OutlinedButton(
                style: TextButton.styleFrom(
                  primary: Colors.blue,
                ),
                onPressed: () {
                  _initiateSession();
                },
                child: const Text("Initiate session"),
              ),
            )
          ],
        ),
      ),

    );
  }


  void _initiateSession() async {
    try {
      AttestrFlowxPlugin.initiateSession(
          handshakeIDController.text,
          clientKeyController.text,
          selectedLocale,
          false,
          {'a':'a'}
      );
    } on PlatformException catch (e) {
      print("Exception: ${e.message}");
    }
  }

  _handleFlowComplete(String message) {
    print(message);
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
      content: Text(message),
    ));
  }

  _handleFlowSkip(String message) {
    print(message);
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
      content: Text(message),
    ));
  }

  _handleFlowError(String message) {
    print(message);
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
      content: Text(message),
    ));
  }

  @override
  void dispose() {
    super.dispose();
    attestrFlowxPlugin.clear();
  }

}
0
likes
135
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter project.

Documentation

API reference

License

MIT (license)

Dependencies

eventify, flutter, plugin_platform_interface

More

Packages that depend on attestr_flowx_plugin

Packages that implement attestr_flowx_plugin