Skip to content
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Google's ML Kit for Flutter is a set of [Flutter plugins](https://flutter.io/pla
| [Pose Detection (Beta)](https://developers.google.com/ml-kit/vision/pose-detection) | [google_mlkit_pose_detection](https://pub.dev/packages/google_mlkit_pose_detection) [![Pub Version](https://img.shields.io/pub/v/google_mlkit_pose_detection)](https://pub.dev/packages/google_mlkit_pose_detection) | [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_pose_detection) | ✅ | ✅ |
| [Selfie Segmentation (Beta)](https://developers.google.com/ml-kit/vision/selfie-segmentation) | [google_mlkit_selfie_segmentation](https://pub.dev/packages/google_mlkit_selfie_segmentation) [![Pub Version](https://img.shields.io/pub/v/google_mlkit_selfie_segmentation)](https://pub.dev/packages/google_mlkit_selfie_segmentation) | [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_selfie_segmentation) | ✅ | ✅ |
| [Subject Segmentation (Beta)](https://developers.google.com/ml-kit/vision/subject-segmentation) | [google_mlkit_subject_segmentation](https://pub.dev/packages/google_mlkit_subject_segmentation) [![Pub Version](https://img.shields.io/pub/v/google_mlkit_subject_segmentation)](https://pub.dev/packages/google_mlkit_subject_segmentation) | [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_subject_segmentation) | ✅ | ❌ |
| [Document Scanner (Beta)](https://developers.google.com/ml-kit/vision/doc-scanner) | [google_mlkit_document_scanner](https://pub.dev/packages/google_mlkit_document_scanner) [![Pub Version](https://img.shields.io/pub/v/google_mlkit_document_scanner)](https://pub.dev/packages/google_mlkit_document_scanner) | [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_document_scanner) | ✅ | ❌ |
| [Document Scanner](https://developers.google.com/ml-kit/vision/doc-scanner) | [google_mlkit_document_scanner](https://pub.dev/packages/google_mlkit_document_scanner) [![Pub Version](https://img.shields.io/pub/v/google_mlkit_document_scanner)](https://pub.dev/packages/google_mlkit_document_scanner) | [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_document_scanner) | ✅ | ❌ |

### Natural Language APIs

Expand Down
149 changes: 69 additions & 80 deletions packages/example/lib/vision_detector_views/document_scanner_view.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'dart:collection';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
import 'package:google_mlkit_document_scanner/google_mlkit_document_scanner.dart';

typedef MenuEntry = DropdownMenuEntry<String>;
const List<String> list = <String>['Select option', 'pdf', 'jpeg', 'pdf-jpeg'];

class DocumentScannerView extends StatefulWidget {
@override
State<DocumentScannerView> createState() => _DocumentScannerViewState();
Expand All @@ -12,7 +16,11 @@ class DocumentScannerView extends StatefulWidget {
class _DocumentScannerViewState extends State<DocumentScannerView> {
DocumentScanner? _documentScanner;
DocumentScanningResult? _result;

static final List<MenuEntry> menuEntries = UnmodifiableListView<MenuEntry>(
list.map<MenuEntry>((String name) => MenuEntry(
value: name,
label:
name == 'Select option' ? name : 'Scan ${name.toUpperCase()}')));
@override
void dispose() {
_documentScanner?.close();
Expand All @@ -27,103 +35,84 @@ class _DocumentScannerViewState extends State<DocumentScannerView> {
centerTitle: true,
elevation: 0,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.document_scanner_outlined,
size: 50,
),
SizedBox(width: 8),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
WidgetStateProperty.all<Color>(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
onPressed: () => startScan(DocumentFormat.pdf),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: const Text(
'Scan PDF',
style: TextStyle(color: Colors.white),
),
body: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.document_scanner_outlined,
size: 50,
),
SizedBox(width: 8),
DropdownMenu<String>(
initialSelection: list.first,
onSelected: (String? value) {
if (value != null) {
if (value == 'pdf') {
startScan({DocumentFormat.pdf});
}
if (value == 'jpeg') {
startScan({DocumentFormat.jpeg});
}
if (value == 'pdf-jpeg') {
startScan(
{DocumentFormat.pdf, DocumentFormat.jpeg});
}
}
},
dropdownMenuEntries: menuEntries),
],
),
if (_result?.pdf != null) ...[
Padding(
padding: const EdgeInsets.only(
top: 16, bottom: 8, right: 8, left: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('PDF Document:')),
),
SizedBox(width: 8),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
WidgetStateProperty.all<Color>(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
onPressed: () => startScan(DocumentFormat.jpeg),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: const Text(
'Scan JPEG',
style: TextStyle(color: Colors.white),
),
SizedBox(
height: 300,
child: PDFView(
filePath: _result!.pdf!.uri,
enableSwipe: true,
swipeHorizontal: true,
autoSpacing: false,
pageFling: false,
),
),
],
),
if (_result?.pdf != null) ...[
Padding(
padding: const EdgeInsets.only(
top: 16, bottom: 8, right: 8, left: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('PDF Document:')),
),
SizedBox(
height: 300,
child: PDFView(
filePath: _result!.pdf!.uri,
enableSwipe: true,
swipeHorizontal: true,
autoSpacing: false,
pageFling: false,
if (_result?.images?.isNotEmpty == true) ...[
Padding(
padding: const EdgeInsets.only(
top: 16, bottom: 8, right: 8, left: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Images [0]:')),
),
),
],
if (_result?.images.isNotEmpty == true) ...[
Padding(
padding: const EdgeInsets.only(
top: 16, bottom: 8, right: 8, left: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Images [0]:')),
),
SizedBox(
height: 400, child: Image.file(File(_result!.images.first))),
SizedBox(
height: 400,
child: Image.file(File(_result!.images!.first))),
],
],
],
),
),
),
);
}

void startScan(DocumentFormat format) async {
void startScan(Set<DocumentFormat> formats) async {
try {
_result = null;
setState(() {});
_documentScanner?.close();
_documentScanner = DocumentScanner(
options: DocumentScannerOptions(
documentFormat: format,
documentFormats: formats,
mode: ScannerMode.full,
isGalleryImport: false,
pageLimit: 1,
Expand Down
28 changes: 6 additions & 22 deletions packages/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: google_ml_kit_example
description: "Demonstrates how to use the google_ml_kit plugin."

resolution: workspace
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=3.4.0 <4.0.0'
flutter: '>=3.22.0'
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"

dependencies:
camera: ^0.11.1
Expand All @@ -21,42 +21,26 @@ dependencies:
path: ^1.9.1
path_provider: ^2.1.5

google_mlkit_commons: any
google_mlkit_commons:
google_mlkit_barcode_scanning:
path: ../google_mlkit_barcode_scanning
google_mlkit_digital_ink_recognition:
path: ../google_mlkit_digital_ink_recognition
google_mlkit_document_scanner:
path: ../google_mlkit_document_scanner
google_mlkit_face_detection:
path: ../google_mlkit_face_detection
google_mlkit_face_mesh_detection:
path: ../google_mlkit_face_mesh_detection
google_mlkit_image_labeling:
path: ../google_mlkit_image_labeling
google_mlkit_object_detection:
path: ../google_mlkit_object_detection
google_mlkit_pose_detection:
path: ../google_mlkit_pose_detection
google_mlkit_selfie_segmentation:
path: ../google_mlkit_selfie_segmentation
google_mlkit_subject_segmentation:
path: ../google_mlkit_subject_segmentation
google_mlkit_text_recognition:
path: ../google_mlkit_text_recognition

google_mlkit_entity_extraction:
path: ../google_mlkit_entity_extraction
google_mlkit_language_id:
path: ../google_mlkit_language_id
google_mlkit_translation:
path: ../google_mlkit_translation
google_mlkit_smart_reply:
path: ../google_mlkit_smart_reply

dependency_overrides:
google_mlkit_commons:
path: ../google_mlkit_commons
# dependency_overrides:
# google_mlkit_commons:

dev_dependencies:
flutter_lints: ^6.0.0
Expand Down
5 changes: 3 additions & 2 deletions packages/google_ml_kit/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ description: "A Flutter plugin to use all APIs from Google's standalone ML Kit f
version: 0.20.0
homepage: https://github.com/flutter-ml/google_ml_kit_flutter
repository: https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_ml_kit
resolution: workspace

environment:
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"

dependencies:
flutter:
Expand Down
5 changes: 3 additions & 2 deletions packages/google_mlkit_barcode_scanning/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ description: "A Flutter plugin to use Google's ML Kit Barcode Scanning to read d
version: 0.14.1
homepage: https://github.com/flutter-ml/google_ml_kit_flutter
repository: https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_barcode_scanning
resolution: workspace

environment:
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"

dependencies:
flutter:
Expand Down
5 changes: 3 additions & 2 deletions packages/google_mlkit_commons/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ description: "A Flutter plugin with commons files to implement google's standalo
version: 0.11.0
homepage: https://github.com/flutter-ml/google_ml_kit_flutter
repository: https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_commons
resolution: workspace

environment:
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"

dependencies:
flutter:
Expand Down
5 changes: 3 additions & 2 deletions packages/google_mlkit_digital_ink_recognition/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ description: "A Flutter plugin to use Google's ML Kit Digital Ink Recognition to
version: 0.14.1
homepage: https://github.com/flutter-ml/google_ml_kit_flutter
repository: https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_digital_ink_recognition
resolution: workspace

environment:
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"

dependencies:
flutter:
Expand Down
9 changes: 7 additions & 2 deletions packages/google_mlkit_document_scanner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The document scanner API provides a high-quality fully fledged UI flow that is c

### iOS

This feature is still in Beta, and it is only available for Android. Stay tune for updates in [Google's website](https://developers.google.com/ml-kit/vision/doc-scanner) and request the feature [here](https://github.com/googlesamples/mlkit/issues).
This feature is only available for Android. Stay tune for updates in [Google's website](https://developers.google.com/ml-kit/vision/doc-scanner) and request the feature [here](https://github.com/googlesamples/mlkit/issues).

### Android

Expand All @@ -70,8 +70,13 @@ This feature is still in Beta, and it is only available for Android. Stay tune f
#### Create an instance of `DocumentScannerOptions`

```dart
// set output document formats
const Set<DocumentFormat> documentFormats = {
DocumentFormat.jpeg,
DocumentFormat.pdf
};
DocumentScannerOptions documentOptions = DocumentScannerOptions(
documentFormat: DocumentFormat.jpeg, // set output document format
documentFormats: documentFormats,
mode: ScannerMode.filter, // to control what features are enabled
pageLimit: 1, // setting a limit to the number of pages scanned
isGalleryImport: true, // importing from the photo gallery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ android {
}

dependencies {
implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1")
implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0-milestone-1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading