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
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
Removed target platform switch.
  • Loading branch information
danielroek committed Dec 23, 2020
commit f8d9e4c1171ee40a74bc7fcaa81829d6fb55214e
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:flutter/foundation.dart';

/// Group of image formats that are comparable across Android and iOS platforms.
enum ImageFormatGroup {
/// The image format does not fit into any specific group.
Expand Down Expand Up @@ -37,30 +35,16 @@ extension ImageFormatGroupName on ImageFormatGroup {
/// returns 'unknown' if platform is not supported
/// or if [ImageFormatGroup] is not supported for the platform
String name() {
if (defaultTargetPlatform == TargetPlatform.android) {
switch (this) {
case ImageFormatGroup.jpeg:
return 'jpeg';
case ImageFormatGroup.yuv420:
return 'yuv420';
case ImageFormatGroup.bgra8888:
case ImageFormatGroup.unknown:
default:
return 'unknown';
}
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
switch (this) {
case ImageFormatGroup.bgra8888:
return 'bgra8888';
case ImageFormatGroup.yuv420:
return 'yuv420';
case ImageFormatGroup.jpeg:
case ImageFormatGroup.unknown:
default:
return 'unknown';
}
switch (this) {
case ImageFormatGroup.bgra8888:
return 'bgra8888';
case ImageFormatGroup.yuv420:
return 'yuv420';
case ImageFormatGroup.jpeg:
return 'jpeg';
case ImageFormatGroup.unknown:
default:
return 'unknown';
}
// unsupported platform
return 'unknown';
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import 'package:camera_platform_interface/src/types/types.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('$ImageFormatGroup tests', () {
test('ImageFormatGroupName extension returns correct values', () {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
expect(ImageFormatGroup.jpeg.name(), 'jpeg');
expect(ImageFormatGroup.yuv420.name(), 'yuv420');
expect(ImageFormatGroup.bgra8888.name(), 'unknown');
expect(ImageFormatGroup.unknown.name(), 'unknown');
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
expect(ImageFormatGroup.bgra8888.name(), 'bgra8888');
expect(ImageFormatGroup.yuv420.name(), 'yuv420');
expect(ImageFormatGroup.jpeg.name(), 'unknown');
expect(ImageFormatGroup.jpeg.name(), 'jpeg');
expect(ImageFormatGroup.unknown.name(), 'unknown');
});
});
Expand Down