Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.2.0

**breaking changes**:
- pickImage now returns XFile instead of PickedFile
- pickVideo now returns XFile instead of PickedFile
- changed LostData file parameter type to XFile

## 1.1.5

* Update Flutter SDK constraint.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'package:image_picker_platform_interface/src/platform_interface/image_picker_platform.dart';
export 'package:image_picker_platform_interface/src/types/types.dart';
export 'package:cross_file/cross_file.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
MethodChannel get channel => _channel;

@override
Future<PickedFile> pickImage({
Future<XFile> pickImage({
@required ImageSource source,
double maxWidth,
double maxHeight,
Expand All @@ -34,7 +34,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
imageQuality: imageQuality,
preferredCameraDevice: preferredCameraDevice,
);
return path != null ? PickedFile(path) : null;
return path != null ? XFile(path) : null;
}

@override
Expand Down Expand Up @@ -72,7 +72,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
}

@override
Future<PickedFile> pickVideo({
Future<XFile> pickVideo({
@required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration maxDuration,
Expand All @@ -82,7 +82,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
maxDuration: maxDuration,
preferredCameraDevice: preferredCameraDevice,
);
return path != null ? PickedFile(path) : null;
return path != null ? XFile(path) : null;
}

@override
Expand Down Expand Up @@ -132,7 +132,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
final String path = result['path'];

return LostData(
file: path != null ? PickedFile(path) : null,
file: path != null ? XFile(path) : null,
exception: exception,
type: retrieveType,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart';
import 'package:image_picker_platform_interface/src/types/types.dart';

import '../../image_picker_platform_interface.dart';

/// The interface that implementations of image_picker must implement.
///
/// Platform implementations should extend this class rather than implement it as `image_picker`
Expand Down Expand Up @@ -115,7 +117,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {

// Next version of the API.

/// Returns a [PickedFile] with the image that was picked.
/// Returns a [XFile] with the image that was picked.
///
/// The `source` argument controls where the image comes from. This can
/// be either [ImageSource.camera] or [ImageSource.gallery].
Expand All @@ -141,7 +143,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
///
/// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost
/// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data.
Future<PickedFile> pickImage({
Future<XFile> pickImage({
@required ImageSource source,
double maxWidth,
double maxHeight,
Expand All @@ -151,7 +153,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
throw UnimplementedError('pickImage() has not been implemented.');
}

/// Returns a [PickedFile] containing the video that was picked.
/// Returns a [XFile] containing the video that was picked.
///
/// The [source] argument controls where the video comes from. This can
/// be either [ImageSource.camera] or [ImageSource.gallery].
Expand All @@ -165,7 +167,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
///
/// In Android, the MainActivity can be destroyed for various fo reasons. If that happens, the result will be lost
/// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data.
Future<PickedFile> pickVideo({
Future<XFile> pickVideo({
@required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration maxDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:cross_file/cross_file.dart';
import 'package:flutter/services.dart';
import 'package:image_picker_platform_interface/src/types/types.dart';

Expand Down Expand Up @@ -31,7 +32,7 @@ class LostData {
/// The file that was lost in a previous [pickImage] or [pickVideo] call due to MainActivity being destroyed.
///
/// Can be null if [exception] exists.
final PickedFile file;
final XFile file;

/// The exception of the last [pickImage] or [pickVideo].
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ description: A common platform interface for the image_picker plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.1.5
version: 1.2.0

dependencies:
flutter:
sdk: flutter
meta: ^1.1.8
http: ^0.12.1
plugin_platform_interface: ^1.0.2
cross_file: ^0.1.0

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'dart:convert';
import 'dart:html' as html;
import 'dart:typed_data';

import 'package:cross_file/cross_file.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';

final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = utf8.encode(expectedStringContents);
Expand All @@ -18,7 +18,7 @@ final String textFileUrl = html.Url.createObjectUrl(textFile);

void main() {
group('Create with an objectUrl', () {
final pickedFile = PickedFile(textFileUrl);
final pickedFile = XFile(textFileUrl);

test('Can be read as a string', () async {
expect(await pickedFile.readAsString(), equals(expectedStringContents));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:cross_file/cross_file.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';

final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = utf8.encode(expectedStringContents);
Expand All @@ -18,7 +18,7 @@ final String textFilePath = textFile.path;

void main() {
group('Create with an objectUrl', () {
final pickedFile = PickedFile(textFilePath);
final pickedFile = XFile(textFilePath);

test('Can be read as a string', () async {
expect(await pickedFile.readAsString(), equals(expectedStringContents));
Expand Down