Skip to main content

anyline_plugin 57.0.1 copy "anyline_plugin: ^57.0.1" to clipboard
anyline_plugin: ^57.0.1 copied to clipboard

Flutter Plugin for Anyline OCR, which allows you to scan all kinds of numbers, characters, text and codes.

example/lib/main.dart

import 'package:anyline_plugin/anyline_infinity_plugin.dart';
import 'package:anyline_plugin/models/wrapper_session_parameters.dart';
import 'package:anyline_plugin_example/env_info.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';

import 'package:anyline_plugin_example/legacy/home.dart';

void main() {
  EnvInfo.initialize();
  runApp(AnylineDemoApp());
}

/// A minimal example of the Anyline Infinity Plugin: initialize the SDK, start
/// a scan with a ScanViewConfig and receive its results. For the complete
/// flow, see the example app and the Infinity Plugin getting started guide:
/// https://documentation.anyline.com/flutter-plugin-component/latest/infinity-plugins/getting-started.html
Future<void> scanWithAnyline() async {
  final infinityPlugin = AnylineInfinityPlugin();

  // Initialize the SDK with your Anyline license key.
  final initResponse = await infinityPlugin.requestSdkInitialization(
    WrapperSessionSdkInitializationRequest(licenseKey: 'YOUR_LICENSE_KEY'),
  );
  if (initResponse.initialized != true) {
    debugPrint(
        'SDK initialization failed: ${initResponse.failInfo?.lastError}');
    return;
  }

  // Subscribe to the scan results before starting the scan: the result
  // stream does not buffer events.
  final subscription = infinityPlugin.onScanResults.listen((results) {
    for (final scanResult
        in results.exportedScanResults ?? const <ExportedScanResult>[]) {
      debugPrint('Scan result: ${scanResult.pluginResult?.toJson()}');
    }
  });

  // Configure how scan results are delivered: here, result images are
  // returned base64-encoded in the result, as PNG.
  final scanResultConfig = WrapperSessionScanResultConfig(
    imageContainer: ExportedScanResultImageContainer(
      encoded: ExportedScanResultImageContainerEncoded(),
    ),
    imageParameters: ExportedScanResultImageParameters(
      format: ExportedScanResultImageFormat.PNG,
      quality: 50,
    ),
  );

  // Start scanning with a ScanViewConfig. The call completes when the scan
  // session ends.
  final scanViewConfig = await rootBundle.loadString(
      'anyline_assets/config/infinity/analog_digital_meter_config.json');
  try {
    final response = await infinityPlugin.requestScanStart(
      WrapperSessionScanStartRequest(
        scanViewConfigContentString: scanViewConfig,
        scanResultConfig: scanResultConfig,
      ),
    );
    debugPrint('Scan session ended: ${response.status}');
  } on PlatformException catch (e) {
    debugPrint('Scan error: ${e.message}');
  } finally {
    await subscription.cancel();
  }
}
12
likes
150
points
607
downloads

Documentation

Documentation
API reference

Publisher

verified publisheranyline.com

Weekly Downloads

Flutter Plugin for Anyline OCR, which allows you to scan all kinds of numbers, characters, text and codes.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, pubspec_parse

More

Packages that depend on anyline_plugin

Packages that implement anyline_plugin