Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add improvement for analyzeImage function #1242

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:18.3.1'
} else {
// Bundled model in app
implementation 'com.google.mlkit:barcode-scanning:17.2.0'
implementation 'com.google.mlkit:barcode-scanning:17.3.0'
}

// org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions.
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.1

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.24.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand All @@ -19,7 +19,7 @@ dependencies:
flutter:
sdk: flutter

image_picker: ^1.0.4
image_picker: ^1.1.2
mobile_scanner:
# When depending on this package from a real application you should use:
# mobile_scanner: ^x.y.z
Expand All @@ -33,7 +33,7 @@ dev_dependencies:
sdk: flutter
integration_test:
sdk: flutter
lint: ^2.0.20
lint: ^2.3.0

flutter:
uses-material-design: true
13 changes: 13 additions & 0 deletions lib/src/mobile_scanner_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,17 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {

await MobileScannerPlatform.instance.dispose();
}

/// Exposes the [addBarcode] method.
///
/// This method is used for adding a barcode to the barcode stream.
/// so when using [analyzeImage] the return value
/// can be used in [MobileScanner] using [onDetect] callback.
void addBarcode(BarcodeCapture? barcode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reasoning behind this change? Why would you want these events to be added to the stream of barcodes that are coming from the camera preview?

The analyzeImage method is distinctly different from the barcode stream, because the barcodes have a different source. Besides, if you aboslutely want this behavior, you can just listen to the barcodes stream and forward events to your own StreamController.

if (_barcodesController.isClosed || barcode == null) {
return;
}

_barcodesController.add(barcode);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
plugin_platform_interface: ^2.0.2
plugin_platform_interface: ^2.1.8
web: ">=0.5.1 <2.0.0"

dev_dependencies:
Expand Down
Loading