forked from X-Wei/flutter_catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:edge_detection/edge_detection.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class EdgeDetectionExample extends StatefulWidget { | ||
const EdgeDetectionExample({Key key}) : super(key: key); | ||
|
||
@override | ||
_EdgeDetectionExampleState createState() => _EdgeDetectionExampleState(); | ||
} | ||
|
||
class _EdgeDetectionExampleState extends State<EdgeDetectionExample> { | ||
String _scannedImgPath; | ||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
const SizedBox(height: 8), | ||
ElevatedButton.icon( | ||
icon: const Icon(Icons.camera), | ||
label: const Text('start'), | ||
onPressed: _doScan, | ||
), | ||
if (_scannedImgPath != null) ...[ | ||
Text(_scannedImgPath), | ||
Expanded( | ||
child: Image.file(File(_scannedImgPath)), | ||
) | ||
] | ||
], | ||
); | ||
} | ||
|
||
Future<void> _doScan() async { | ||
/// This [detectEdge] is the only method exposed by the plugin, it'll open | ||
/// the camera and do the scanning. | ||
/// !Unfortunately we cannot customize the behavior like loading image from | ||
/// !gallery or changing the saved image path. | ||
final imgPath = await EdgeDetection.detectEdge; | ||
setState(() => _scannedImgPath = imgPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters