Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4b3c599
Migrate image picker platform interface to cross_file
BeMacized Jun 21, 2021
c4c5de4
[image_picker] Implemented changes for cross_file migration
BeMacized Jun 21, 2021
44aa4c5
[image_picker] migrated web implementation to cross_file
BeMacized Jun 22, 2021
e39fa1f
Reverted changes to web implementation to move to separate PR
BeMacized Jun 23, 2021
f4fbd0c
[image_picker_for_web] Migration to cross_file
BeMacized Jun 23, 2021
2de19b4
Merge branch 'master' into issue/70886
BeMacized Jun 30, 2021
86f604b
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jun 30, 2021
7b39862
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jun 30, 2021
68e2ef8
Re-added old methods and marked them as deprecated.
BeMacized Jun 30, 2021
d345b37
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jun 30, 2021
a0ab00e
Update to match platform interface changes
BeMacized Jun 30, 2021
875704e
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jun 30, 2021
a987170
Format & annotate deprecated classes.
BeMacized Jun 30, 2021
6ab2bb0
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jun 30, 2021
5900446
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jun 30, 2021
217949d
Updated to match platform interface changes
BeMacized Jun 30, 2021
3fa10b9
Updated pubspec and changelog.
BeMacized Jun 30, 2021
c1ff8b2
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jun 30, 2021
addfe99
Updated platform interface dependency version
BeMacized Jun 30, 2021
6d329e6
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jun 30, 2021
aefff73
Updated changelog and pubspec version
BeMacized Jun 30, 2021
f5a4163
Updated pubspec version and changelog
BeMacized Jun 30, 2021
2c4cd91
Fix analysis issues for deprecations
BeMacized Jul 2, 2021
69969b2
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jul 2, 2021
129efcb
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jul 2, 2021
29e0c40
Remove Deprecation tags so we don't break consumers of this package o…
ditman Jul 8, 2021
c74cebb
Merge branch 'master' into issue/70886
ditman Jul 8, 2021
0a082c8
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jul 8, 2021
043db42
Merge branch 'issue/70886' into issue/70886-impl-android-ios
BeMacized Jul 8, 2021
4615db1
Temporary platform interface reference dependency
BeMacized Jul 8, 2021
d3662f6
Merge branch 'issue/70886-impl-web' into issue/70886-impl-android-ios
BeMacized Jul 8, 2021
84ee0a2
Temporary dependency update
BeMacized Jul 8, 2021
faa1a99
Implement PR feedback
BeMacized Jul 8, 2021
afa61ab
Merge branch 'issue/70886' into issue/70886-impl-web
BeMacized Jul 8, 2021
b29ec7f
Merge branch 'issue/70886-impl-web' into issue/70886-impl-android-ios
BeMacized Jul 8, 2021
756633b
Update platform interface and web implementation dependency references
BeMacized Jul 13, 2021
c1131d5
Merge branch 'master' into issue/70886-impl-android-ios
BeMacized Jul 13, 2021
c7fd236
Update documentation
BeMacized Jul 13, 2021
8c89c99
Fix merge issues
BeMacized Jul 13, 2021
8073e7a
Fix merge issues
BeMacized Jul 13, 2021
bda48dd
Move tests of deprecated methods to new file, and ignore warnings the…
ditman Jul 14, 2021
a9534fe
Update Changelog to mention the deprecation of the current methods, a…
ditman Jul 14, 2021
e59bb03
Remove unnecessary ignore_for_file from plugin code.
ditman Jul 14, 2021
dc0e7eb
Merge branch 'master' into issue/70886-impl-android-ios
ditman Jul 16, 2021
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
Prev Previous commit
Next Next commit
Fix analysis issues for deprecations
  • Loading branch information
BeMacized committed Jul 2, 2021
commit 2c4cd91c2f3f1923516ffe330e67817eaf02fac0
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
MethodChannel get channel => _channel;

@override
@Deprecated('Switch to using getImage instead')
Future<PickedFile?> pickImage({
required ImageSource source,
double? maxWidth,
Expand All @@ -37,6 +38,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
}

@override
@Deprecated('Switch to using getMultiImage instead')
Future<List<PickedFile>?> pickMultiImage({
double? maxWidth,
double? maxHeight,
Expand Down Expand Up @@ -117,6 +119,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
}

@override
@Deprecated('Switch to using getVideo instead')
Future<PickedFile?> pickVideo({
required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Expand Down Expand Up @@ -146,6 +149,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
}

@override
@Deprecated("Switch to using getLostData instead")
Future<LostData> retrieveLostData() async {
final Map<String, dynamic>? result =
await _channel.invokeMapMethod<String, dynamic>('retrieve');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
/// See also:
/// * [LostData], for what's included in the response.
/// * [Android Activity Lifecycle](https://developer.android.com/reference/android/app/Activity.html), for more information on MainActivity destruction.
@Deprecated("Switch to using getLostData instead")
Future<LostData> retrieveLostData() {
throw UnimplementedError('retrieveLostData() has not been implemented.');
}
Expand Down Expand Up @@ -173,7 +174,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
/// to work on an Android device.
///
/// 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.
/// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data.
///
/// If no images were picked, the return value is null.
Future<XFile?> getImage({
Expand Down Expand Up @@ -225,7 +226,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
/// Defaults to [CameraDevice.rear].
///
/// 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.
/// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data.
///
/// If no images were picked, the return value is null.
Future<XFile?> getVideo({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ void main() {

group('#pickImage', () {
test('passes the image source argument correctly', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(source: ImageSource.camera);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(source: ImageSource.gallery);

expect(
Expand All @@ -54,30 +56,37 @@ void main() {
});

test('passes the width and height arguments correctly', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(source: ImageSource.camera);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxWidth: 10.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxHeight: 10.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxWidth: 10.0,
maxHeight: 20.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxWidth: 10.0,
imageQuality: 70,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxHeight: 10.0,
imageQuality: 70,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
maxWidth: 10.0,
Expand Down Expand Up @@ -143,34 +152,40 @@ void main() {

test('does not accept a invalid imageQuality argument', () {
expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickImage(imageQuality: -1, source: ImageSource.gallery),
throwsArgumentError,
);

expect(
() =>
// ignore: deprecated_member_use_from_same_package
picker.pickImage(imageQuality: 101, source: ImageSource.gallery),
throwsArgumentError,
);

expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickImage(imageQuality: -1, source: ImageSource.camera),
throwsArgumentError,
);

expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickImage(imageQuality: 101, source: ImageSource.camera),
throwsArgumentError,
);
});

test('does not accept a negative width or height argument', () {
expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickImage(source: ImageSource.camera, maxWidth: -1.0),
throwsArgumentError,
);

expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickImage(source: ImageSource.camera, maxHeight: -1.0),
throwsArgumentError,
);
Expand All @@ -180,11 +195,14 @@ void main() {
picker.channel
.setMockMethodCallHandler((MethodCall methodCall) => null);

// ignore: deprecated_member_use_from_same_package
expect(await picker.pickImage(source: ImageSource.gallery), isNull);
// ignore: deprecated_member_use_from_same_package
expect(await picker.pickImage(source: ImageSource.camera), isNull);
});

test('camera position defaults to back', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(source: ImageSource.camera);

expect(
Expand All @@ -202,6 +220,7 @@ void main() {
});

test('camera position can set to front', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickImage(
source: ImageSource.camera,
preferredCameraDevice: CameraDevice.front);
Expand All @@ -224,6 +243,7 @@ void main() {
group('#pickMultiImage', () {
test('calls the method correctly', () async {
returnValue = ['0', '1'];
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage();

expect(
Expand All @@ -240,25 +260,32 @@ void main() {

test('passes the width and height arguments correctly', () async {
returnValue = ['0', '1'];
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage();
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxWidth: 10.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxHeight: 10.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxWidth: 10.0,
maxHeight: 20.0,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxWidth: 10.0,
imageQuality: 70,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxHeight: 10.0,
imageQuality: 70,
);
// ignore: deprecated_member_use_from_same_package
await picker.pickMultiImage(
maxWidth: 10.0,
maxHeight: 20.0,
Expand Down Expand Up @@ -310,11 +337,13 @@ void main() {
test('does not accept a negative width or height argument', () {
returnValue = ['0', '1'];
expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickMultiImage(maxWidth: -1.0),
throwsArgumentError,
);

expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickMultiImage(maxHeight: -1.0),
throwsArgumentError,
);
Expand All @@ -323,11 +352,13 @@ void main() {
test('does not accept a invalid imageQuality argument', () {
returnValue = ['0', '1'];
expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickMultiImage(imageQuality: -1),
throwsArgumentError,
);

expect(
// ignore: deprecated_member_use_from_same_package
() => picker.pickMultiImage(imageQuality: 101),
throwsArgumentError,
);
Expand All @@ -337,14 +368,18 @@ void main() {
picker.channel
.setMockMethodCallHandler((MethodCall methodCall) => null);

// ignore: deprecated_member_use_from_same_package
expect(await picker.pickMultiImage(), isNull);
// ignore: deprecated_member_use_from_same_package
expect(await picker.pickMultiImage(), isNull);
});
});

group('#pickVideo', () {
test('passes the image source argument correctly', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(source: ImageSource.camera);
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(source: ImageSource.gallery);

expect(
Expand All @@ -365,15 +400,19 @@ void main() {
});

test('passes the duration argument correctly', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(source: ImageSource.camera);
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(
source: ImageSource.camera,
maxDuration: const Duration(seconds: 10),
);
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(
source: ImageSource.camera,
maxDuration: const Duration(minutes: 1),
);
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(
source: ImageSource.camera,
maxDuration: const Duration(hours: 1),
Expand Down Expand Up @@ -409,11 +448,14 @@ void main() {
picker.channel
.setMockMethodCallHandler((MethodCall methodCall) => null);

// ignore: deprecated_member_use_from_same_package
expect(await picker.pickVideo(source: ImageSource.gallery), isNull);
// ignore: deprecated_member_use_from_same_package
expect(await picker.pickVideo(source: ImageSource.camera), isNull);
});

test('camera position defaults to back', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(source: ImageSource.camera);

expect(
Expand All @@ -429,6 +471,7 @@ void main() {
});

test('camera position can set to front', () async {
// ignore: deprecated_member_use_from_same_package
await picker.pickVideo(
source: ImageSource.camera,
preferredCameraDevice: CameraDevice.front,
Expand Down Expand Up @@ -482,6 +525,7 @@ void main() {
picker.channel.setMockMethodCallHandler((MethodCall methodCall) async {
return null;
});
// ignore: deprecated_member_use_from_same_package
expect((await picker.retrieveLostData()).isEmpty, true);
});

Expand All @@ -494,6 +538,7 @@ void main() {
'path': '/example/path',
};
});
// ignore: deprecated_member_use_from_same_package
expect(picker.retrieveLostData(), throwsAssertionError);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final String textFileUrl = html.Url.createObjectUrl(textFile);

void main() {
group('Create with an objectUrl', () {
// ignore: deprecated_member_use_from_same_package
final pickedFile = PickedFile(textFileUrl);

test('Can be read as a string', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final String textFilePath = textFile.path;

void main() {
group('Create with an objectUrl', () {
// ignore: deprecated_member_use_from_same_package
final PickedFile pickedFile = PickedFile(textFilePath);

test('Can be read as a string', () async {
Expand Down