confirmAndUploadNewImage function
- BuildContext context, {
- required CropHelper cropHelper,
- required bool isLoggedInMandatory,
- UserPictureSource? forcedSource,
Lets the user pick a picture, crop it, and save it.
Implementation
Future<CropParameters?> confirmAndUploadNewImage(
BuildContext context, {
required CropHelper cropHelper,
required bool isLoggedInMandatory,
UserPictureSource? forcedSource,
}) async {
final XFile? fullPhoto = await pickImageFile(
context,
forcedSource: forcedSource,
);
if (fullPhoto == null) {
return null;
}
if (!context.mounted) {
return null;
}
return Navigator.of(context).push<CropParameters>(
MaterialPageRoute<CropParameters>(
builder: (BuildContext context) => CropPage(
inputFile: File(fullPhoto.path),
initiallyDifferent: true,
isLoggedInMandatory: isLoggedInMandatory,
cropHelper: cropHelper,
onRetakePhoto: () => pickImageFile(
context,
forcedSource: forcedSource,
).then((XFile? file) => file != null ? File(file.path) : null),
),
fullscreenDialog: true,
),
);
}