Implementation

The following is an example MetaMapPage class with the MetaMap method implementation:

import 'package:flutter/material.dart';
import 'package:metamap_plugin_flutter/metamap_plugin_flutter.dart';
import 'package:fluttertoast/fluttertoast.dart';


class MetaMapPage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MetaMapPage createState() => _MetaMapPage();
}

class _MetaMapPage extends State<MyHomePage> {

  void showMetaMapFlow() {
    MetaMapFlutter.showMetaMapFlow(clientId:"YOUR_CLIENT_ID", flowId:"YOUR_FLOW_ID");
    MetaMapFlutter.resultCompleter.future.then((result) => Fluttertoast.showToast(
      if (result) {
        print("Success ${result.verificationId}")
      } else {
        print("Cancelled")
      }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("MetaMap flutter plugin demo"),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: showMetaMapFlow,
          child: const Text('Verify me'),
        )
      )
    );
  }
}

In order to make this work you need to set your own CLIENT_ID and FLOW_ID. You can find them in the Metamap Dashboard, for more details please check this section.