D1APP-22 image picker
This commit is contained in:
parent
900023e43c
commit
a103f0e574
|
|
@ -0,0 +1,20 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:image_cropper/image_cropper.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
|
class MediaService {
|
||||||
|
static Future<File?> pickImage({required ImageSource source}) async {
|
||||||
|
final imagePicker = ImagePicker();
|
||||||
|
final XFile? pickedFile = await imagePicker.pickImage(source: source);
|
||||||
|
if (pickedFile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final cropedFile = await ImageCropper.cropImage(
|
||||||
|
sourcePath: pickedFile.path,
|
||||||
|
aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
|
||||||
|
compressQuality: 70,
|
||||||
|
);
|
||||||
|
return cropedFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue