Skip to content

Commit

Permalink
add EdgeDetectionExample
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Jan 23, 2021
1 parent 8691395 commit 0f791a5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/my_app_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import 'routes/persistence_hive_ex.dart';
import 'routes/persistence_preference_ex.dart';
import 'routes/persistence_sembast_ex.dart';
import 'routes/persistence_sqlite_ex.dart';
import 'routes/multimedia_edge_detection_ex.dart';
import 'routes/plugins_feature_discovery_ex.dart';
import 'routes/plugins_image_ex.dart';
import 'routes/plugins_local_auth_ex.dart';
Expand Down Expand Up @@ -678,6 +679,13 @@ const kMyAppRoutesAdvanced = <MyRouteGroup>[
description: 'Video/audio player plugin by the flutter team.',
links: {'Pub': 'https://pub.dev/packages/video_player'},
),
MyRoute(
child: EdgeDetectionExample(),
sourceFilePath: 'lib/routes/multimedia_edge_detection_ex.dart',
title: 'Edge Detection',
description: 'Plugin to scan documents.',
links: {'Pub': 'https://pub.dev/packages/edge_detection'},
),
],
),
MyRouteGroup(
Expand Down
43 changes: 43 additions & 0 deletions lib/routes/multimedia_edge_detection_ex.dart
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);
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
charts_flutter: 0.9.0
cloud_firestore: 0.14.1+3
convex_bottom_bar: ^2.6.0
edge_detection: ^1.0.5
english_words: 3.1.5
extended_image: ^1.3.1-dev
feature_discovery: ^0.13.0+2
Expand Down

0 comments on commit 0f791a5

Please sign in to comment.