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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'AppName',
      debugShowCheckedModeBanner: false,
      themeMode: ThemeMode.light,
      home: View(),
    );
  }
}

class View extends StatefulWidget {
  const View({Key? key}) : super(key: key);

  static const platform = MethodChannel('flutter.native/myid');

  @override
  State<View> createState() => _ViewState();
}

class _ViewState extends State<View> {
  var result = "";

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          TextButton(
            onPressed: () {
              View.platform.invokeMethod('runSDK', <String, dynamic>{
                'KEY_PHONE_NUMBER': "1234567", // Organization phone number
                'KEY_CLIENT_ID': "",
                'KEY_PASSPORT_DATA': "AB1234567",
                'KEY_DATE_OF_BIRTH': "01.09.1999", // Format: dd.MM.yyyy
                'KEY_SDK_HASH': "", // Optional
                'KEY_EXTERNAL_ID': "", // Optional
                'KEY_THRESHOLD': 0.5, // 0.5 until 1.0
                'KEY_BUILD_MODE': "PRODUCTION", // PRODUCTION or DEBUG
                'KEY_ENTRY_TYPE': "AUTH", // AUTH or FACE
                'KEY_LOCALE': "uz", // uz, en, ru
                'KEY_CAMERA_SHAPE': "CIRCLE", // CIRCLE or ELLIPSE
                'KEY_WITH_PHOTO': false
              }).then((value) => setState(() => result = value));
            },
            child: const Text("Run myID SDK"),
          ),
          Text(
            "Result is: " + result,
            style: const TextStyle(fontSize: 26),
          ),
        ],
      ),
    );
  }
}
