mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:48:56 +03:30
27 lines
662 B
Dart
Executable File
27 lines
662 B
Dart
Executable File
import 'package:barcode_scan2/platform_wrapper.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
Future<String> scan() async {
|
|
try {
|
|
var barcode = await BarcodeScanner.scan();
|
|
if (barcode.type.name == 'Cancelled') {
|
|
return 'cancel';
|
|
} else if (barcode.type.name == 'Failed') {
|
|
return 'error';
|
|
}
|
|
try {
|
|
var id = barcode.rawContent.contains('www.cssd-doc.com')
|
|
? barcode.rawContent.split('/')[5]
|
|
: barcode.rawContent;
|
|
|
|
return id;
|
|
} catch (_) {
|
|
return 'null';
|
|
}
|
|
} on PlatformException catch (_) {
|
|
return 'access';
|
|
} catch (_) {
|
|
return 'error';
|
|
}
|
|
}
|