Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ImageService #2265

Merged
merged 14 commits into from
Dec 27, 2023
6 changes: 2 additions & 4 deletions lib/services/image_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class ImageService {

/// Crops the image selected by the user.
///
/// Accepts a `File` type image and returns a `Future<File?>` of the cropped image.
///
/// **params**:
/// * `imageFile`: the image file to be cropped.
///
Expand Down Expand Up @@ -56,7 +54,7 @@ class ImageService {
}
} catch (e) {
throw Exception(
"ImageService : Exception occurred while cropping Image.",
"ImageService : $e.",
);
}
Azad99-9 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -66,7 +64,7 @@ class ImageService {
/// Converts the image into Base64 format.
///
/// **params**:
/// * `file`: Takes the image in format of file.
/// * `file`:Image as a File object.
Azad99-9 marked this conversation as resolved.
Show resolved Hide resolved
///
/// **returns**:
/// * `Future<String?>`: image in string format
Expand Down
17 changes: 12 additions & 5 deletions lib/services/third_party_service/multi_media_pick_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ class MultiMediaPickerService {
_imageService = imageService;
}

//Local Variables
/// Controller for handling the stream of selected files.
final StreamController<File> _fileStreamController = StreamController();

/// Stream of selected files.
late Stream<File> _fileStream;

/// [ImagePicker] used for selecting images or videos.
late ImagePicker _picker;

/// [ImageService] for additional image-related operations.
late ImageService _imageService;
//Getters

/// Returns the stream of files.
/// Provides a stream of selected multimedia files.
///
/// params:
/// None.
Expand All @@ -48,7 +53,6 @@ class MultiMediaPickerService {
/// Picks the image from gallery or to click the image from user's camera.
///
/// First ask for the permission to access the camera, if denied then returns a message in.
///
/// custom Dialog Box. Returns a File type for which `camera` variable is false by default.
///
/// **params**:
Expand Down Expand Up @@ -85,7 +89,10 @@ class MultiMediaPickerService {
return null;
}

/// Returns the permission denied dialog.
/// Generates a custom alert dialog for permission denial.
///
/// When called, it creates and returns a `CustomAlertDialog` widget with pre-defined settings.
/// This dialog prompts the user to grant camera permissions from the app settings.
///
/// **params**:
/// None
Expand Down
5 changes: 3 additions & 2 deletions test/service_tests/image_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ void main() {
uiSettings: anyNamed('uiSettings'),
),
).thenAnswer((realInvocation) async => croppedFile);

final file = await imageService.cropImage(imageFile: fakefile);
// verify(mockImageCropper.cropImage(sourcePath: fakefile.path));

expect(file?.path, croppedFile.path);
});

Expand Down Expand Up @@ -80,7 +81,7 @@ void main() {
//using this asset as the test asset
final file = File('assets/images/Group 8948.png');
final fileString = await imageService.convertToBase64(file);
print(fileString);
expect(fileString, isA<String>());
Azad99-9 marked this conversation as resolved.
Show resolved Hide resolved
});

test(
Expand Down
Loading