Pick and resize image flow, how to implement it fluently

Viewed 49

I need to provide a flow for the user to pick an image, resize it and store it. I have the user profile picture with a InkWell and the following onTap method

var original = await ImagePicker().pickImage(source: ImageSource.gallery);
if (original == null) return;
File croppedFile = await ImageCropper().cropImage(
   sourcePath: original.path,
   aspectRatioPresets: [CropAspectRatioPreset.square],
   androidUiSettings: AndroidUiSettings(
       toolbarColor: Palette.primary,
       lockAspectRatio: false),
   iosUiSettings: IOSUiSettings(
   minimumAspectRatio: 1.0,
));
if (croppedFile != null) upload(croppedFile);

This works fine. However the ImagePicker and the ImageResizer are two different plugins and two different flows. I need to await the first and then move to the second.

This creates a weird behaviour for the user. While moving from picker to resizer the screen goes back for few seconds to the main UserPage

How can I avoid that? How can I make these two plugins' flow fluently move one from each other without this small time-frame?

I guess this is due to the picker frame being removed from the stack and then the resizer one being added.

0 Answers
Related