-
Notifications
You must be signed in to change notification settings - Fork 0
/
title_finder.dart
48 lines (43 loc) · 1.31 KB
/
title_finder.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
import 'package:flutter/material.dart';
import 'package:flutter_camera_ml_vision/flutter_camera_ml_vision.dart';
class ScanPage extends StatefulWidget {
ScanPage({Key key, this.title}) : super(key: key);
final String title;
@override
_ScanPageState createState() => _ScanPageState();
}
class _ScanPageState extends State<ScanPage> {
bool resultSent = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Scan a book"),
),
body: Column(
children: <Widget>[
Expanded(
child: SafeArea(
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: CameraMlVision<VisionText>(
detector: FirebaseVision.instance.textRecognizer().processImage,
onResult: (VisionText words) {
if (!mounted || resultSent) {
return;
}
if (words.blocks.isNotEmpty) {
resultSent = true;
Navigator.of(context).pop<VisionText>(words);
}
},
),
),
),
),
],
),
);
}
}