Khoren Markosyan
2 years ago
37 changed files with 892 additions and 408 deletions
@ -1,10 +1,45 @@ |
|||||||
# This file tracks properties of this Flutter project. |
# This file tracks properties of this Flutter project. |
||||||
# Used by Flutter tool to assess capabilities and perform upgrades etc. |
# Used by Flutter tool to assess capabilities and perform upgrades etc. |
||||||
# |
# |
||||||
# This file should be version controlled and should not be manually edited. |
# This file should be version controlled. |
||||||
|
|
||||||
version: |
version: |
||||||
revision: 7e9793dee1b85a243edd0e06cb1658e98b077561 |
revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
channel: stable |
channel: stable |
||||||
|
|
||||||
project_type: app |
project_type: app |
||||||
|
|
||||||
|
# Tracks metadata for the flutter migrate command |
||||||
|
migration: |
||||||
|
platforms: |
||||||
|
- platform: root |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: android |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: ios |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: linux |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: macos |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: web |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: windows |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
|
||||||
|
# User provided section |
||||||
|
|
||||||
|
# List of Local paths (relative to this file) that should be |
||||||
|
# ignored by the migrate tool. |
||||||
|
# |
||||||
|
# Files that are not part of the templates will be ignored by default. |
||||||
|
unmanaged_files: |
||||||
|
- 'lib/main.dart' |
||||||
|
- 'ios/Runner.xcodeproj/project.pbxproj' |
||||||
|
@ -0,0 +1,6 @@ |
|||||||
|
package com.markosyan.example |
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity |
||||||
|
|
||||||
|
class MainActivity: FlutterActivity() { |
||||||
|
} |
After Width: | Height: | Size: 917 B |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,58 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<!-- |
||||||
|
If you are serving your web app in a path other than the root, change the |
||||||
|
href value below to reflect the base path you are serving from. |
||||||
|
|
||||||
|
The path provided below has to start and end with a slash "/" in order for |
||||||
|
it to work correctly. |
||||||
|
|
||||||
|
For more details: |
||||||
|
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base |
||||||
|
|
||||||
|
This is a placeholder for base href that will be replaced by the value of |
||||||
|
the `--base-href` argument provided to `flutter build`. |
||||||
|
--> |
||||||
|
<base href="$FLUTTER_BASE_HREF"> |
||||||
|
|
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> |
||||||
|
<meta name="description" content="A new Flutter project."> |
||||||
|
|
||||||
|
<!-- iOS meta tags & icons --> |
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes"> |
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
||||||
|
<meta name="apple-mobile-web-app-title" content="example"> |
||||||
|
<link rel="apple-touch-icon" href="icons/Icon-192.png"> |
||||||
|
|
||||||
|
<!-- Favicon --> |
||||||
|
<link rel="icon" type="image/png" href="favicon.png"/> |
||||||
|
|
||||||
|
<title>example</title> |
||||||
|
<link rel="manifest" href="manifest.json"> |
||||||
|
|
||||||
|
<script> |
||||||
|
// The value below is injected by flutter build, do not touch. |
||||||
|
var serviceWorkerVersion = null; |
||||||
|
</script> |
||||||
|
<!-- This script adds the flutter initialization JS code --> |
||||||
|
<script src="flutter.js" defer></script> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<script> |
||||||
|
window.addEventListener('load', function(ev) { |
||||||
|
// Download main.dart.js |
||||||
|
_flutter.loader.loadEntrypoint({ |
||||||
|
serviceWorker: { |
||||||
|
serviceWorkerVersion: serviceWorkerVersion, |
||||||
|
} |
||||||
|
}).then(function(engineInitializer) { |
||||||
|
return engineInitializer.initializeEngine(); |
||||||
|
}).then(function(appRunner) { |
||||||
|
return appRunner.runApp(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,35 @@ |
|||||||
|
{ |
||||||
|
"name": "example", |
||||||
|
"short_name": "example", |
||||||
|
"start_url": ".", |
||||||
|
"display": "standalone", |
||||||
|
"background_color": "#0175C2", |
||||||
|
"theme_color": "#0175C2", |
||||||
|
"description": "A new Flutter project.", |
||||||
|
"orientation": "portrait-primary", |
||||||
|
"prefer_related_applications": false, |
||||||
|
"icons": [ |
||||||
|
{ |
||||||
|
"src": "icons/Icon-192.png", |
||||||
|
"sizes": "192x192", |
||||||
|
"type": "image/png" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"src": "icons/Icon-512.png", |
||||||
|
"sizes": "512x512", |
||||||
|
"type": "image/png" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"src": "icons/Icon-maskable-192.png", |
||||||
|
"sizes": "192x192", |
||||||
|
"type": "image/png", |
||||||
|
"purpose": "maskable" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"src": "icons/Icon-maskable-512.png", |
||||||
|
"sizes": "512x512", |
||||||
|
"type": "image/png", |
||||||
|
"purpose": "maskable" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -1,10 +1,95 @@ |
|||||||
export 'generated_bindings.dart'; |
import 'dart:typed_data'; |
||||||
export 'src/logic/zxing.dart'; |
|
||||||
export 'src/ui/dynamic_scanner_overlay.dart'; |
import 'package:camera/camera.dart'; |
||||||
export 'src/ui/fixed_scanner_overlay.dart'; |
import 'src/models/models.dart'; |
||||||
export 'src/ui/reader_widget.dart'; |
|
||||||
export 'src/ui/scanner_overlay.dart'; |
import 'zxing_cross.dart' |
||||||
export 'src/ui/writer_widget.dart'; |
if (dart.library.io) 'zxing_mobile.dart' |
||||||
export 'src/utils/extentions.dart'; |
if (dart.library.html) 'zxing_web.dart'; |
||||||
export 'src/utils/image_converter.dart'; |
|
||||||
export 'src/utils/messages.dart'; |
export 'src/models/models.dart'; |
||||||
|
export 'src/ui/ui.dart'; |
||||||
|
|
||||||
|
final Zxing zx = Zxing(); |
||||||
|
|
||||||
|
abstract class Zxing { |
||||||
|
/// factory constructor to return the correct implementation. |
||||||
|
factory Zxing() => getZxing(); |
||||||
|
|
||||||
|
String version() => ''; |
||||||
|
void setLogEnabled(bool enabled) {} |
||||||
|
String barcodeFormatName(int format) => ''; |
||||||
|
|
||||||
|
Encode encodeBarcode( |
||||||
|
String contents, { |
||||||
|
int format = Format.qrCode, |
||||||
|
int width = 300, |
||||||
|
int height = 300, |
||||||
|
int margin = 0, |
||||||
|
int eccLevel = 0, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Starts reading barcode from the camera |
||||||
|
Future<void> startCameraProcessing(); |
||||||
|
|
||||||
|
/// Stops reading barcode from the camera |
||||||
|
void stopCameraProcessing(); |
||||||
|
|
||||||
|
/// Reads barcode from the camera |
||||||
|
Future<Code> processCameraImage( |
||||||
|
CameraImage image, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcode from String image path |
||||||
|
Future<Code?> readBarcodeImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcode from XFile image path |
||||||
|
Future<Code?> readBarcodeImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcode from image url |
||||||
|
Future<Code?> readBarcodeImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
// Reads barcode from Uint8List image bytes |
||||||
|
Code readBarcode( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcodes from String image path |
||||||
|
Future<List<Code>> readBarcodesImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcodes from XFile image path |
||||||
|
Future<List<Code>> readBarcodesImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcodes from image url |
||||||
|
Future<List<Code>> readBarcodesImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Reads barcodes from Uint8List image bytes |
||||||
|
List<Code> readBarcodes( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}); |
||||||
|
} |
||||||
|
@ -1,20 +1,22 @@ |
|||||||
part of 'zxing.dart'; |
part of 'zxing.dart'; |
||||||
|
|
||||||
// Encode a string into a barcode |
// Encode a string into a barcode |
||||||
EncodeResult encodeBarcode( |
Encode zxingEncodeBarcode( |
||||||
String contents, { |
String contents, { |
||||||
int format = Format.QRCode, |
int format = Format.qrCode, |
||||||
int width = 300, |
int width = 300, |
||||||
int height = 300, |
int height = 300, |
||||||
int margin = 0, |
int margin = 0, |
||||||
int eccLevel = 0, |
int eccLevel = 0, |
||||||
}) { |
}) { |
||||||
return bindings.encodeBarcode( |
return bindings |
||||||
contents.toNativeUtf8().cast<Char>(), |
.encodeBarcode( |
||||||
width, |
contents.toNativeUtf8().cast<Char>(), |
||||||
height, |
width, |
||||||
format, |
height, |
||||||
margin, |
format, |
||||||
eccLevel, |
margin, |
||||||
); |
eccLevel, |
||||||
|
) |
||||||
|
.toEncode(); |
||||||
} |
} |
||||||
|
@ -1,100 +1,72 @@ |
|||||||
part of 'zxing.dart'; |
part of 'zxing.dart'; |
||||||
|
|
||||||
/// Reads barcodes from String image path |
/// Reads barcodes from String image path |
||||||
Future<List<CodeResult>> readBarcodesImagePathString( |
Future<List<Code>> zxingReadBarcodesImagePathString( |
||||||
String path, { |
String path, { |
||||||
int format = Format.Any, |
Params? params, |
||||||
int cropWidth = 0, |
|
||||||
int cropHeight = 0, |
|
||||||
bool tryHarder = false, |
|
||||||
bool tryRotate = true, |
|
||||||
}) => |
}) => |
||||||
readBarcodesImagePath( |
zxingReadBarcodesImagePath( |
||||||
XFile(path), |
XFile(path), |
||||||
format: format, |
params: params, |
||||||
cropWidth: cropWidth, |
|
||||||
cropHeight: cropHeight, |
|
||||||
tryHarder: tryHarder, |
|
||||||
tryRotate: tryRotate, |
|
||||||
); |
); |
||||||
|
|
||||||
/// Reads barcodes from XFile image path |
/// Reads barcodes from XFile image path |
||||||
Future<List<CodeResult>> readBarcodesImagePath( |
Future<List<Code>> zxingReadBarcodesImagePath( |
||||||
XFile path, { |
XFile path, { |
||||||
int format = Format.Any, |
Params? params, |
||||||
int cropWidth = 0, |
|
||||||
int cropHeight = 0, |
|
||||||
bool tryHarder = false, |
|
||||||
bool tryRotate = true, |
|
||||||
}) async { |
}) async { |
||||||
final Uint8List imageBytes = await path.readAsBytes(); |
final Uint8List imageBytes = await path.readAsBytes(); |
||||||
final imglib.Image? image = imglib.decodeImage(imageBytes); |
final imglib.Image? image = imglib.decodeImage(imageBytes); |
||||||
if (image == null) { |
if (image == null) { |
||||||
return <CodeResult>[]; |
return <Code>[]; |
||||||
} |
} |
||||||
return readBarcodes( |
return zxingReadBarcodes( |
||||||
image.getBytes(format: imglib.Format.luminance), |
image.getBytes(format: imglib.Format.luminance), |
||||||
width: image.width, |
width: image.width, |
||||||
height: image.height, |
height: image.height, |
||||||
format: format, |
params: params, |
||||||
cropWidth: cropWidth, |
|
||||||
cropHeight: cropHeight, |
|
||||||
tryHarder: tryHarder, |
|
||||||
tryRotate: tryRotate, |
|
||||||
); |
); |
||||||
} |
} |
||||||
|
|
||||||
/// Reads barcodes from image url |
/// Reads barcodes from image url |
||||||
Future<List<CodeResult>> readBarcodesImageUrl( |
Future<List<Code>> zxingReadBarcodesImageUrl( |
||||||
String url, { |
String url, { |
||||||
int format = Format.Any, |
Params? params, |
||||||
int cropWidth = 0, |
|
||||||
int cropHeight = 0, |
|
||||||
bool tryHarder = false, |
|
||||||
bool tryRotate = true, |
|
||||||
}) async { |
}) async { |
||||||
final Uint8List imageBytes = |
final Uint8List imageBytes = |
||||||
(await NetworkAssetBundle(Uri.parse(url)).load(url)).buffer.asUint8List(); |
(await NetworkAssetBundle(Uri.parse(url)).load(url)).buffer.asUint8List(); |
||||||
final imglib.Image? image = imglib.decodeImage(imageBytes); |
final imglib.Image? image = imglib.decodeImage(imageBytes); |
||||||
if (image == null) { |
if (image == null) { |
||||||
return <CodeResult>[]; |
return <Code>[]; |
||||||
} |
} |
||||||
return readBarcodes( |
return zxingReadBarcodes( |
||||||
image.getBytes(format: imglib.Format.luminance), |
image.getBytes(format: imglib.Format.luminance), |
||||||
width: image.width, |
width: image.width, |
||||||
height: image.height, |
height: image.height, |
||||||
format: format, |
params: params, |
||||||
cropWidth: cropWidth, |
|
||||||
cropHeight: cropHeight, |
|
||||||
tryHarder: tryHarder, |
|
||||||
tryRotate: tryRotate, |
|
||||||
); |
); |
||||||
} |
} |
||||||
|
|
||||||
/// Reads barcodes from Uint8List image bytes |
/// Reads barcodes from Uint8List image bytes |
||||||
List<CodeResult> readBarcodes( |
List<Code> zxingReadBarcodes( |
||||||
Uint8List bytes, { |
Uint8List bytes, { |
||||||
required int width, |
required int width, |
||||||
required int height, |
required int height, |
||||||
int format = Format.Any, |
Params? params, |
||||||
int cropWidth = 0, |
|
||||||
int cropHeight = 0, |
|
||||||
bool tryHarder = false, |
|
||||||
bool tryRotate = true, |
|
||||||
}) { |
}) { |
||||||
final CodeResults result = bindings.readBarcodes( |
final CodeResults result = bindings.readBarcodes( |
||||||
bytes.allocatePointer(), |
bytes.allocatePointer(), |
||||||
format, |
params?.format ?? Format.any, |
||||||
width, |
width, |
||||||
height, |
height, |
||||||
cropWidth, |
params?.cropWidth ?? 0, |
||||||
cropHeight, |
params?.cropHeight ?? 0, |
||||||
tryHarder ? 1 : 0, |
params?.tryHarder ?? false ? 1 : 0, |
||||||
tryRotate ? 1 : 0, |
params?.tryRotate ?? true ? 1 : 0, |
||||||
); |
); |
||||||
final List<CodeResult> results = <CodeResult>[]; |
final List<Code> results = <Code>[]; |
||||||
for (int i = 0; i < result.count; i++) { |
for (int i = 0; i < result.count; i++) { |
||||||
results.add(result.results.elementAt(i).ref); |
results.add(result.results.elementAt(i).ref.toCode()); |
||||||
} |
} |
||||||
return results; |
return results; |
||||||
} |
} |
||||||
|
@ -0,0 +1,20 @@ |
|||||||
|
import 'dart:typed_data'; |
||||||
|
|
||||||
|
import 'position.dart'; |
||||||
|
|
||||||
|
// Represents a barcode code |
||||||
|
class Code { |
||||||
|
Code( |
||||||
|
this.isValid, |
||||||
|
this.text, |
||||||
|
this.rawBytes, |
||||||
|
this.format, |
||||||
|
this.position, |
||||||
|
); |
||||||
|
|
||||||
|
bool isValid; // Whether the code is valid |
||||||
|
String? text; // The text of the code |
||||||
|
Uint8List? rawBytes; // The raw bytes of the code |
||||||
|
int? format; // The format of the code |
||||||
|
Position? position; // The position of the code |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
import 'dart:typed_data'; |
||||||
|
|
||||||
|
// Encapsulates the result of encoding a barcode. |
||||||
|
class Encode { |
||||||
|
Encode( |
||||||
|
this.isValid, |
||||||
|
this.format, |
||||||
|
this.text, |
||||||
|
this.data, |
||||||
|
this.length, |
||||||
|
this.error, |
||||||
|
); |
||||||
|
|
||||||
|
bool isValid; // Whether the code is valid |
||||||
|
int? format; // The format of the code |
||||||
|
String? text; // The text of the code |
||||||
|
Uint32List? data; // The raw bytes of the code |
||||||
|
int? length; // The length of the raw bytes |
||||||
|
String? error; // The error message |
||||||
|
} |
@ -0,0 +1,82 @@ |
|||||||
|
// Format Enumerates barcode formats known to this package. |
||||||
|
abstract class Format { |
||||||
|
// Used as a return value if no valid barcode has been detected |
||||||
|
static const int none = 0; |
||||||
|
|
||||||
|
static const int aztec = 1 << 0; // Aztec (2D) |
||||||
|
static const int codabar = 1 << 1; // Codabar (1D) |
||||||
|
static const int code39 = 1 << 2; // Code39 (1D) |
||||||
|
static const int code93 = 1 << 3; // Code93 (1D) |
||||||
|
static const int code128 = 1 << 4; // Code128 (1D) |
||||||
|
static const int dataBar = 1 << 5; // GS1 DataBar |
||||||
|
static const int dataBarExpanded = 1 << 6; // GS1 DataBar Expanded |
||||||
|
static const int dataMatrix = 1 << 7; // DataMatrix (2D) |
||||||
|
static const int ean8 = 1 << 8; // EAN-8 (1D) |
||||||
|
static const int ean13 = 1 << 9; // EAN-13 (1D) |
||||||
|
static const int itf = 1 << 10; // ITF (Interleaved Two of Five) (1D) |
||||||
|
static const int maxiCode = 1 << 11; // MaxiCode (2D) |
||||||
|
static const int pdf417 = 1 << 12; // PDF417 (1D) or (2D) |
||||||
|
static const int qrCode = 1 << 13; // QR Code (2D) |
||||||
|
static const int upca = 1 << 14; // UPC-A (1D) |
||||||
|
static const int upce = 1 << 15; // UPC-E (1D) |
||||||
|
|
||||||
|
static const int oneDCodes = codabar | |
||||||
|
code39 | |
||||||
|
code93 | |
||||||
|
code128 | |
||||||
|
ean8 | |
||||||
|
ean13 | |
||||||
|
itf | |
||||||
|
dataBar | |
||||||
|
dataBarExpanded | |
||||||
|
upca | |
||||||
|
upce; |
||||||
|
static const int twoDCodes = aztec | dataMatrix | maxiCode | pdf417 | qrCode; |
||||||
|
static const int any = oneDCodes | twoDCodes; |
||||||
|
} |
||||||
|
|
||||||
|
extension CodeFormat on Format { |
||||||
|
String get name => formatNames[this] ?? 'Unknown'; |
||||||
|
|
||||||
|
static final List<int> writerFormats = <int>[ |
||||||
|
Format.qrCode, |
||||||
|
Format.dataMatrix, |
||||||
|
Format.aztec, |
||||||
|
Format.pdf417, |
||||||
|
Format.codabar, |
||||||
|
Format.code39, |
||||||
|
Format.code93, |
||||||
|
Format.code128, |
||||||
|
Format.ean8, |
||||||
|
Format.ean13, |
||||||
|
Format.itf, |
||||||
|
Format.upca, |
||||||
|
Format.upce, |
||||||
|
// Format.dataBar, |
||||||
|
// Format.dataBarExpanded, |
||||||
|
// Format.maxiCode, |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
final Map<int, String> formatNames = <int, String>{ |
||||||
|
Format.none: 'None', |
||||||
|
Format.aztec: 'Aztec', |
||||||
|
Format.codabar: 'CodaBar', |
||||||
|
Format.code39: 'Code39', |
||||||
|
Format.code93: 'Code93', |
||||||
|
Format.code128: 'Code128', |
||||||
|
Format.dataBar: 'DataBar', |
||||||
|
Format.dataBarExpanded: 'DataBarExpanded', |
||||||
|
Format.dataMatrix: 'DataMatrix', |
||||||
|
Format.ean8: 'EAN8', |
||||||
|
Format.ean13: 'EAN13', |
||||||
|
Format.itf: 'ITF', |
||||||
|
Format.maxiCode: 'MaxiCode', |
||||||
|
Format.pdf417: 'PDF417', |
||||||
|
Format.qrCode: 'QR Code', |
||||||
|
Format.upca: 'UPCA', |
||||||
|
Format.upce: 'UPCE', |
||||||
|
Format.oneDCodes: 'OneD', |
||||||
|
Format.twoDCodes: 'TwoD', |
||||||
|
Format.any: 'Any', |
||||||
|
}; |
@ -1,3 +1,4 @@ |
|||||||
|
// Contains the messages used in the app |
||||||
class Messages { |
class Messages { |
||||||
const Messages({ |
const Messages({ |
||||||
this.createButton = 'Create', |
this.createButton = 'Create', |
@ -0,0 +1,6 @@ |
|||||||
|
export 'code.dart'; |
||||||
|
export 'encode.dart'; |
||||||
|
export 'format.dart'; |
||||||
|
export 'messages.dart'; |
||||||
|
export 'params.dart'; |
||||||
|
export 'position.dart'; |
@ -0,0 +1,22 @@ |
|||||||
|
import 'dart:core'; |
||||||
|
|
||||||
|
import 'format.dart'; |
||||||
|
|
||||||
|
// Represents the parameters for decoding a barcode |
||||||
|
class Params { |
||||||
|
Params({ |
||||||
|
this.format = Format.any, |
||||||
|
this.cropWidth = 0, |
||||||
|
this.cropHeight = 0, |
||||||
|
this.tryHarder = false, |
||||||
|
this.tryRotate = true, |
||||||
|
this.tryInverted = false, |
||||||
|
}); |
||||||
|
|
||||||
|
int format; |
||||||
|
int cropWidth; |
||||||
|
int cropHeight; |
||||||
|
bool tryHarder; |
||||||
|
bool tryRotate; |
||||||
|
bool tryInverted; |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
/// Represents the position of a barcode in an image. |
||||||
|
class Position { |
||||||
|
Position( |
||||||
|
this.topLeftX, |
||||||
|
this.topLeftY, |
||||||
|
this.topRightX, |
||||||
|
this.topRightY, |
||||||
|
this.bottomLeftX, |
||||||
|
this.bottomLeftY, |
||||||
|
this.bottomRightX, |
||||||
|
this.bottomRightY, |
||||||
|
); |
||||||
|
|
||||||
|
int topLeftX; // x coordinate of top left corner of barcode |
||||||
|
int topLeftY; // y coordinate of top left corner of barcode |
||||||
|
int topRightX; // x coordinate of top right corner of barcode |
||||||
|
int topRightY; // y coordinate of top right corner of barcode |
||||||
|
int bottomLeftX; // x coordinate of bottom left corner of barcode |
||||||
|
int bottomLeftY; // y coordinate of bottom left corner of barcode |
||||||
|
int bottomRightX; // x coordinate of bottom right corner of barcode |
||||||
|
int bottomRightY; // y coordinate of bottom right corner of barcode |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
export 'dynamic_scanner_overlay.dart'; |
||||||
|
export 'fixed_scanner_overlay.dart'; |
||||||
|
export 'reader_widget.dart'; |
||||||
|
export 'scanner_overlay.dart'; |
||||||
|
export 'writer_widget.dart'; |
@ -0,0 +1,4 @@ |
|||||||
|
import 'flutter_zxing.dart'; |
||||||
|
|
||||||
|
Zxing getZxing() => throw UnsupportedError( |
||||||
|
'Cannot create an instance of FlutterZxing on the current platform.'); |
@ -0,0 +1,149 @@ |
|||||||
|
import 'dart:typed_data'; |
||||||
|
|
||||||
|
import 'package:camera/camera.dart'; |
||||||
|
|
||||||
|
import 'flutter_zxing.dart'; |
||||||
|
import 'src/logic/zxing.dart'; |
||||||
|
|
||||||
|
export 'generated_bindings.dart'; |
||||||
|
export 'src/logic/zxing.dart'; |
||||||
|
export 'src/models/models.dart'; |
||||||
|
export 'src/utils/extentions.dart'; |
||||||
|
export 'src/utils/image_converter.dart'; |
||||||
|
|
||||||
|
Zxing getZxing() => ZxingMobile(); |
||||||
|
|
||||||
|
class ZxingMobile implements Zxing { |
||||||
|
ZxingMobile(); |
||||||
|
|
||||||
|
@override |
||||||
|
String version() => zxingVersion(); |
||||||
|
|
||||||
|
@override |
||||||
|
void setLogEnabled(bool enabled) => setZxingLogEnabled(enabled); |
||||||
|
|
||||||
|
@override |
||||||
|
String barcodeFormatName(int format) => zxingBarcodeFormatName(format); |
||||||
|
|
||||||
|
@override |
||||||
|
Encode encodeBarcode( |
||||||
|
String contents, { |
||||||
|
int format = Format.qrCode, |
||||||
|
int width = 300, |
||||||
|
int height = 300, |
||||||
|
int margin = 0, |
||||||
|
int eccLevel = 0, |
||||||
|
}) => |
||||||
|
zxingEncodeBarcode( |
||||||
|
contents, |
||||||
|
format: format, |
||||||
|
width: width, |
||||||
|
height: height, |
||||||
|
margin: margin, |
||||||
|
eccLevel: eccLevel, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<void> startCameraProcessing() => zxingStartCameraProcessing(); |
||||||
|
|
||||||
|
@override |
||||||
|
void stopCameraProcessing() => zxingStopCameraProcessing(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code> processCameraImage( |
||||||
|
CameraImage image, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingProcessCameraImage( |
||||||
|
image, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodeImagePathString( |
||||||
|
path, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodeImagePath( |
||||||
|
path, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodeImageUrl( |
||||||
|
url, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Code readBarcode( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcode( |
||||||
|
bytes, |
||||||
|
width: width, |
||||||
|
height: height, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodesImagePathString( |
||||||
|
path, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodesImagePath( |
||||||
|
path, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodesImageUrl( |
||||||
|
url, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
|
||||||
|
@override |
||||||
|
List<Code> readBarcodes( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
zxingReadBarcodes( |
||||||
|
bytes, |
||||||
|
width: width, |
||||||
|
height: height, |
||||||
|
params: params, |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,104 @@ |
|||||||
|
import 'dart:typed_data'; |
||||||
|
|
||||||
|
import 'package:camera/camera.dart'; |
||||||
|
|
||||||
|
import 'flutter_zxing.dart'; |
||||||
|
|
||||||
|
Zxing getZxing() => ZxingWeb(); |
||||||
|
|
||||||
|
class ZxingWeb implements Zxing { |
||||||
|
ZxingWeb(); |
||||||
|
|
||||||
|
@override |
||||||
|
String version() => 'Unsupported'; |
||||||
|
|
||||||
|
@override |
||||||
|
void setLogEnabled(bool enabled) {} |
||||||
|
|
||||||
|
@override |
||||||
|
String barcodeFormatName(int format) => 'Unsupported'; |
||||||
|
|
||||||
|
@override |
||||||
|
Encode encodeBarcode( |
||||||
|
String contents, { |
||||||
|
int format = Format.qrCode, |
||||||
|
int width = 300, |
||||||
|
int height = 300, |
||||||
|
int margin = 0, |
||||||
|
int eccLevel = 0, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<void> startCameraProcessing() => throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
void stopCameraProcessing() => throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code> processCameraImage( |
||||||
|
CameraImage image, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<Code?> readBarcodeImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Code readBarcode( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImagePathString( |
||||||
|
String path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImagePath( |
||||||
|
XFile path, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<List<Code>> readBarcodesImageUrl( |
||||||
|
String url, { |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
|
||||||
|
@override |
||||||
|
List<Code> readBarcodes( |
||||||
|
Uint8List bytes, { |
||||||
|
required int width, |
||||||
|
required int height, |
||||||
|
Params? params, |
||||||
|
}) => |
||||||
|
throw UnimplementedError(); |
||||||
|
} |
Loading…
Reference in new issue