contours_plugin_demo 0.0.1 copy "contours_plugin_demo: ^0.0.1" to clipboard
contours_plugin_demo: ^0.0.1 copied to clipboard

contoursdemo.

example/lib/main.dart

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

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

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _base64Front = "";
  final _contoursPluginDemoPlugin = ContoursPluginDemo();

  String b64 =
    'iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==';


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

    final channel = MethodChannel('contours_response_plugin');
    channel.setMethodCallHandler((call) async {
      if (call.method == 'capturedImageFrontCropped') {
        dynamic myResult = call.arguments;
        setState(() {
          _base64Front = myResult;
        });
      }
      if (call.method == 'capturedImageRearCropped') {
      }
      if (call.method == 'capturedImageFront') {
      }
      if (call.method == 'capturedImageRear') {
      }
      if (call.method == 'capturedImageRearCropped') {
      }
      if (call.method == 'eventMethod') {
        dynamic myResult = call.arguments;
        setState(() {
          _platformVersion = myResult;
        });
      }
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await _contoursPluginDemoPlugin.getPlatformVersion() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;


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

  @override
  Widget build(BuildContext context) {
    Uint8List bytesImage = const Base64Decoder().convert(_base64Front);
    
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(child: Image.memory(bytesImage, width: 1200, height: 800)),
      ),
    );
  }
}
0
likes
140
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

contoursdemo.

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on contours_plugin_demo

Packages that implement contours_plugin_demo