|
4 | 4 |
|
5 | 5 | import 'dart:async';
|
6 | 6 |
|
| 7 | +import 'package:cross_file/cross_file.dart'; |
7 | 8 | import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
8 |
| - |
9 | 9 | import 'package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart';
|
10 | 10 | import 'package:image_picker_platform_interface/src/types/types.dart';
|
11 | 11 |
|
@@ -144,4 +144,111 @@ abstract class ImagePickerPlatform extends PlatformInterface {
|
144 | 144 | Future<LostData> retrieveLostData() {
|
145 | 145 | throw UnimplementedError('retrieveLostData() has not been implemented.');
|
146 | 146 | }
|
| 147 | + |
| 148 | + /// Returns an [XFile] with the image that was picked. |
| 149 | + /// |
| 150 | + /// The `source` argument controls where the image comes from. This can |
| 151 | + /// be either [ImageSource.camera] or [ImageSource.gallery]. |
| 152 | + /// |
| 153 | + /// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used |
| 154 | + /// in addition to a size modification, of which the usage is explained below. |
| 155 | + /// |
| 156 | + /// If specified, the image will be at most `maxWidth` wide and |
| 157 | + /// `maxHeight` tall. Otherwise the image will be returned at it's |
| 158 | + /// original width and height. |
| 159 | + /// |
| 160 | + /// The `imageQuality` argument modifies the quality of the image, ranging from 0-100 |
| 161 | + /// where 100 is the original/max quality. If `imageQuality` is null, the image with |
| 162 | + /// the original quality will be returned. Compression is only supported for certain |
| 163 | + /// image types such as JPEG. If compression is not supported for the image that is picked, |
| 164 | + /// a warning message will be logged. |
| 165 | + /// |
| 166 | + /// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera]. |
| 167 | + /// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device. |
| 168 | + /// Defaults to [CameraDevice.rear]. Note that Android has no documented parameter for an intent to specify if |
| 169 | + /// the front or rear camera should be opened, this function is not guaranteed |
| 170 | + /// to work on an Android device. |
| 171 | + /// |
| 172 | + /// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost |
| 173 | + /// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data. |
| 174 | + /// |
| 175 | + /// If no images were picked, the return value is null. |
| 176 | + Future<XFile?> getImage({ |
| 177 | + required ImageSource source, |
| 178 | + double? maxWidth, |
| 179 | + double? maxHeight, |
| 180 | + int? imageQuality, |
| 181 | + CameraDevice preferredCameraDevice = CameraDevice.rear, |
| 182 | + }) { |
| 183 | + throw UnimplementedError('getImage() has not been implemented.'); |
| 184 | + } |
| 185 | + |
| 186 | + /// Returns a [List<XFile>] with the images that were picked. |
| 187 | + /// |
| 188 | + /// The images come from the [ImageSource.gallery]. |
| 189 | + /// |
| 190 | + /// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used |
| 191 | + /// in addition to a size modification, of which the usage is explained below. |
| 192 | + /// |
| 193 | + /// If specified, the image will be at most `maxWidth` wide and |
| 194 | + /// `maxHeight` tall. Otherwise the image will be returned at it's |
| 195 | + /// original width and height. |
| 196 | + /// |
| 197 | + /// The `imageQuality` argument modifies the quality of the images, ranging from 0-100 |
| 198 | + /// where 100 is the original/max quality. If `imageQuality` is null, the images with |
| 199 | + /// the original quality will be returned. Compression is only supported for certain |
| 200 | + /// image types such as JPEG. If compression is not supported for the image that is picked, |
| 201 | + /// a warning message will be logged. |
| 202 | + /// |
| 203 | + /// If no images were picked, the return value is null. |
| 204 | + Future<List<XFile>?> getMultiImage({ |
| 205 | + double? maxWidth, |
| 206 | + double? maxHeight, |
| 207 | + int? imageQuality, |
| 208 | + }) { |
| 209 | + throw UnimplementedError('getMultiImage() has not been implemented.'); |
| 210 | + } |
| 211 | + |
| 212 | + /// Returns a [XFile] containing the video that was picked. |
| 213 | + /// |
| 214 | + /// The [source] argument controls where the video comes from. This can |
| 215 | + /// be either [ImageSource.camera] or [ImageSource.gallery]. |
| 216 | + /// |
| 217 | + /// The [maxDuration] argument specifies the maximum duration of the captured video. If no [maxDuration] is specified, |
| 218 | + /// the maximum duration will be infinite. |
| 219 | + /// |
| 220 | + /// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera]. |
| 221 | + /// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device. |
| 222 | + /// Defaults to [CameraDevice.rear]. |
| 223 | + /// |
| 224 | + /// In Android, the MainActivity can be destroyed for various fo reasons. If that happens, the result will be lost |
| 225 | + /// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data. |
| 226 | + /// |
| 227 | + /// If no images were picked, the return value is null. |
| 228 | + Future<XFile?> getVideo({ |
| 229 | + required ImageSource source, |
| 230 | + CameraDevice preferredCameraDevice = CameraDevice.rear, |
| 231 | + Duration? maxDuration, |
| 232 | + }) { |
| 233 | + throw UnimplementedError('getVideo() has not been implemented.'); |
| 234 | + } |
| 235 | + |
| 236 | + /// Retrieve the lost [XFile] file when [getImage], [getMultiImage] or [getVideo] failed because the MainActivity is |
| 237 | + /// destroyed. (Android only) |
| 238 | + /// |
| 239 | + /// Image or video can be lost if the MainActivity is destroyed. And there is no guarantee that the MainActivity is |
| 240 | + /// always alive. Call this method to retrieve the lost data and process the data according to your APP's business logic. |
| 241 | + /// |
| 242 | + /// Returns a [LostDataResponse] object if successfully retrieved the lost data. The [LostDataResponse] object can |
| 243 | + /// represent either a successful image/video selection, or a failure. |
| 244 | + /// |
| 245 | + /// Calling this on a non-Android platform will throw [UnimplementedError] exception. |
| 246 | + /// |
| 247 | + /// See also: |
| 248 | + /// * [LostDataResponse], for what's included in the response. |
| 249 | + /// * [Android Activity Lifecycle](https://developer.android.com/reference/android/app/Activity.html), for more |
| 250 | + /// information on MainActivity destruction. |
| 251 | + Future<LostDataResponse> getLostData() { |
| 252 | + throw UnimplementedError('getLostData() has not been implemented.'); |
| 253 | + } |
147 | 254 | }
|
0 commit comments