123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import 'dart:async';
- import 'dart:typed_data';
- import 'package:flutter/services.dart';
- export 'package:r_scan/src/r_scan_view.dart';
- export 'package:r_scan/src/r_scan_camera.dart';
- class RScan {
- static const MethodChannel _channel =
- const MethodChannel('com.rhyme_lph/r_scan');
-
-
-
- static Future<RScanResult> scanImagePath(String path) async =>
- RScanResult.formMap(await _channel.invokeMethod('scanImagePath', {
- "path": path,
- }));
-
-
-
- static Future<RScanResult> scanImageUrl(String url) async =>
- RScanResult.formMap(await _channel.invokeMethod('scanImageUrl', {
- "url": url,
- }));
-
-
-
- static Future<RScanResult> scanImageMemory(Uint8List uint8list) async =>
- RScanResult.formMap(await _channel.invokeMethod('scanImageMemory', {
- "uint8list": uint8list,
- }));
- }
- enum RScanBarType {
- azetc,
- codabar,
- code_39,
- code_93,
- code_128,
- data_matrix,
- ean_8,
- ean_13,
- itf,
- maxicode,
- pdf_417,
- qr_code,
- rss_14,
- rss_expanded,
- upc_a,
- upc_e,
- upc_ean_extension,
- }
- class RScanPoint {
-
- final double x;
-
- final double y;
- RScanPoint(this.x, this.y);
- @override
- String toString() {
- return 'RScanPoint{x: $x, y: $y}';
- }
- @override
- bool operator ==(Object other) =>
- identical(this, other) ||
- other is RScanPoint &&
- runtimeType == other.runtimeType &&
- x == other.x &&
- y == other.y;
- @override
- int get hashCode => x.hashCode ^ y.hashCode;
- }
- class RScanResult {
-
- final RScanBarType type;
-
- final String message;
-
- final List<RScanPoint> points;
- const RScanResult({this.type, this.message, this.points});
- factory RScanResult.formMap(Map map) {
- return map == null
- ? null
- : RScanResult(
- type: map['type'] != null
- ? RScanBarType.values[map['type'] as int]
- : null,
- message: map['message'] as String,
- points: map['points'] != null
- ? (map['points'] as List)
- .map(
- (data) => RScanPoint(
- data['X'],
- data['Y'],
- ),
- )
- .toList()
- : null,
- );
- }
- @override
- String toString() {
- return 'RScanResult{type: $type, message: $message, points: $points}';
- }
- @override
- bool operator ==(Object other) =>
- identical(this, other) ||
- other is RScanResult &&
- runtimeType == other.runtimeType &&
- type == other.type &&
- message == other.message &&
- points == other.points;
- @override
- int get hashCode => type.hashCode ^ message.hashCode ^ points.hashCode;
- }
|