Skip to content

Commit a0fd236

Browse files
committed
update example
1 parent 66d131c commit a0fd236

File tree

8 files changed

+38
-7
lines changed

8 files changed

+38
-7
lines changed

example/ios/Runner/Info.plist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>NSPhotoLibraryUsageDescription</key>
6+
<string>Pick Images</string>
7+
<key>NSCameraUsageDescription</key>
8+
<string>Take a picture</string>
9+
<key>NSMicrophoneUsageDescription</key>
10+
<string>Record a video</string>
511
<key>CFBundleDevelopmentRegion</key>
612
<string>$(DEVELOPMENT_LANGUAGE)</string>
713
<key>CFBundleDisplayName</key>

example/lib/main.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:typed_data';
44
import 'package:flutter/foundation.dart';
55
import 'package:flutter/material.dart';
66
import 'package:opencv_dart/opencv_dart.dart' as cv;
7+
import 'package:image_picker/image_picker.dart';
78

89
void main() {
910
runApp(const MyApp());
@@ -54,6 +55,24 @@ class _MyAppState extends State<MyApp> {
5455
alignment: Alignment.center,
5556
child: Column(
5657
children: [
58+
ElevatedButton(
59+
onPressed: () async {
60+
final picker = ImagePicker();
61+
final img = await picker.pickImage(source: ImageSource.gallery);
62+
if (img != null) {
63+
final path = img.path;
64+
final mat = cv.imread(path);
65+
print("cv.imread: width: ${mat.cols}, height: ${mat.rows}, path: $path");
66+
final bytes = cv.imencode(".png", mat);
67+
// heavy computation
68+
final (gray, blur) = await heavyTask(bytes);
69+
setState(() {
70+
images = [bytes, gray, blur];
71+
});
72+
}
73+
},
74+
child: const Text("Pick Image"),
75+
),
5776
ElevatedButton(
5877
onPressed: () async {
5978
final data = await DefaultAssetBundle.of(context).load("images/lenna.png");

example/linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <file_selector_linux/file_selector_plugin.h>
910

1011
void fl_register_plugins(FlPluginRegistry* registry) {
12+
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
13+
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
14+
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
1115
}

example/linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
file_selector_linux
67
)
78

89
list(APPEND FLUTTER_FFI_PLUGIN_LIST

example/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import file_selector_macos
89

910
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11+
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
1012
}

example/pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ dependencies:
3131
flutter:
3232
sdk: flutter
3333

34-
opencv_dart:
35-
path: ../
34+
opencv_dart: ^1.0.0+1
3635

3736
# The following adds the Cupertino Icons font to your application.
3837
# Use with the CupertinoIcons class for iOS style icons.
3938
cupertino_icons: ^1.0.2
40-
camera_universal: ^0.0.3
39+
image_picker: ^1.0.7
4140

4241
dev_dependencies:
4342
flutter_test:

example/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#include "generated_plugin_registrant.h"
88

9-
#include <camera_windows/camera_windows.h>
9+
#include <file_selector_windows/file_selector_windows.h>
1010

1111
void RegisterPlugins(flutter::PluginRegistry* registry) {
12-
CameraWindowsRegisterWithRegistrar(
13-
registry->GetRegistrarForPlugin("CameraWindows"));
12+
FileSelectorWindowsRegisterWithRegistrar(
13+
registry->GetRegistrarForPlugin("FileSelectorWindows"));
1414
}

example/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6-
camera_windows
6+
file_selector_windows
77
)
88

99
list(APPEND FLUTTER_FFI_PLUGIN_LIST

0 commit comments

Comments
 (0)