diff --git a/image_cropper/ohos/example/lib/main.dart b/image_cropper/ohos/example/lib/main.dart index 80f3ed9fc3b594e5ab89287d73552891a7ddba25..30ff01e123732d9462dc572f5c9a6b015bfb545c 100644 --- a/image_cropper/ohos/example/lib/main.dart +++ b/image_cropper/ohos/example/lib/main.dart @@ -3,8 +3,8 @@ import 'dart:io'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; import 'package:imagecropper_ohos_example/crop_page.dart'; +import 'package:file_picker_ohos/file_picker_ohos.dart'; void main() { runApp(const MyApp()); @@ -282,12 +282,16 @@ class _HomePageState extends State { } Future _uploadImage() async { - final pickedFile = - await ImagePicker().pickImage(source: ImageSource.gallery); - if (pickedFile != null) { - setState(() { - _pickedFile = pickedFile.path; - }); + FilePickerResult? result = await FilePicker.platform.pickFiles(type:FileType.image); + if (result != null) { + File pickedFile = File(result.files.single.path!); + if (pickedFile != null) { + setState(() { + _pickedFile = pickedFile.path; + }); + } + } else { + // User canceled the picker } } diff --git a/image_cropper/ohos/example/ohos/entry/oh-package.json5 b/image_cropper/ohos/example/ohos/entry/oh-package.json5 index 003cdb2c961558521e310bf0ae54b0b0526b1c29..7b4e6fae71b9d662e1de0c56e6f3ae018a94e7a2 100644 --- a/image_cropper/ohos/example/ohos/entry/oh-package.json5 +++ b/image_cropper/ohos/example/ohos/entry/oh-package.json5 @@ -7,7 +7,7 @@ "license": "", "dependencies": { "@ohos/flutter_ohos": "file:../har/flutter.har", - "imagecropper_ohos": "file:..\\har\\imagecropper_ohos.har", - "image_picker_ohos": "file:..\\har\\image_picker_ohos.har" + "imagecropper_ohos": "file:../har/imagecropper_ohos.har", + "file_picker_ohos": "file:../har/file_picker_ohos.har" } } \ No newline at end of file diff --git a/image_cropper/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets b/image_cropper/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets index ee71d568257612b30a226f42fc5d72348e756a3b..0aa747fc6e18b9269408930abfe21ddc96ef2b91 100644 --- a/image_cropper/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets +++ b/image_cropper/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets @@ -14,7 +14,7 @@ */ import { FlutterEngine, Log } from '@ohos/flutter_ohos'; -import ImagePickerPlugin from 'image_picker_ohos'; +import FilePickerPlugin from 'file_picker_ohos'; import ImagecropperOhosPlugin from 'imagecropper_ohos'; /** @@ -29,7 +29,7 @@ export class GeneratedPluginRegistrant { static registerWith(flutterEngine: FlutterEngine) { try { - flutterEngine.getPlugins()?.add(new ImagePickerPlugin()); + flutterEngine.getPlugins()?.add(new FilePickerPlugin()); flutterEngine.getPlugins()?.add(new ImagecropperOhosPlugin()); } catch (e) { Log.e( diff --git a/image_cropper/ohos/example/ohos/oh-package.json5 b/image_cropper/ohos/example/ohos/oh-package.json5 index 07c4aaf2bea8f33efcce4840a796690d7cc81af6..bbf5a6aaa51fd17bd7d525d24231cdb7772945c9 100644 --- a/image_cropper/ohos/example/ohos/oh-package.json5 +++ b/image_cropper/ohos/example/ohos/oh-package.json5 @@ -16,6 +16,6 @@ "@ohos/flutter_ohos": "file:./har/flutter.har", "imagecropper_ohos": "file:./har/imagecropper_ohos.har", "@ohos/flutter_module": "file:./entry", - "image_picker_ohos": "file:./har/image_picker_ohos.har" + "file_picker_ohos": "file:./har/file_picker_ohos.har" } } \ No newline at end of file diff --git a/image_cropper/ohos/example/pubspec.yaml b/image_cropper/ohos/example/pubspec.yaml index 94e36a387992dd7a95e0198f4f545fc8e8c45a63..d5a05b595a01cd9dd44c85304247e8170f9cea9b 100644 --- a/image_cropper/ohos/example/pubspec.yaml +++ b/image_cropper/ohos/example/pubspec.yaml @@ -29,17 +29,16 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 dotted_border: ^2.1.0 - image_picker: + file_picker: git: - url: https://gitee.com/openharmony-sig/flutter_packages.git - path: packages/image_picker/image_picker + url: https://gitee.com/openharmony-sig/fluttertpc_file_picker.git dependency_overrides: - image_picker_ohos: + file_picker_ohos: git: - url: https://gitee.com/openharmony-sig/flutter_packages.git - path: packages/image_picker/image_picker_ohos - ref: br_optimize_har_structure + url: https://gitee.com/openharmony-sig/fluttertpc_file_picker.git + path: ohos + dev_dependencies: flutter_test: