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

fix: Null error when picking no picture #1124

Merged
merged 3 commits into from
Feb 13, 2022
Merged

Conversation

M123-dev
Copy link
Member

What

  • Fixes a null error when picking no picture since Navigator.pop() doesn't stop the build method

Fixes bug(s)

@M123-dev M123-dev requested a review from a team as a code owner February 12, 2022 10:56
@M123-dev M123-dev linked an issue Feb 12, 2022 that may be closed by this pull request
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @M123-dev!

Perhaps your code fixes the issue, but I believe the flaw is upstream.

I don't believe in FutureBuilders. What about using LoadingDialog?

  1. I'm on a page
  2. I click on a button that runs async code
  3. which opens a "running" dialog with "close" button
  4. and when the code is over, the dialog is automatically closed
  5. and only then you go to your ImageCropPage with an already fully loaded image

Feel free to ignore my comment if you want your fix to be merged quickly.

@@ -26,6 +26,14 @@ class ImageCropPage extends StatelessWidget {
return pickedXFile.readAsBytes();
}

// We need this callback to stop flutter from complaining that we pop while
// returning a placeholder container
void popCallback(Function() callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should at least be private.

@github-actions github-actions bot added 🌐 l10n Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users. 🥫 Product page labels Feb 12, 2022
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @M123-dev!
Looks much clearer without the FutureBuilder, doesn't it?
Please read my comment, as maybe you've added a superfluous dialog.

Comment on lines 15 to 19
final Uint8List? bytes = await LoadingDialog.run<Uint8List?>(
context: context,
future: pickImage(),
title: appLocalizations.selecting_photo,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I would use a LoadingDialog here as the user has control over what's going on: picking an image. Just calling await picImage(); instead?
But maybe there's something I miss about UX: I never use that part of the app, as I cannot scan.

Copy link
Member Author

@M123-dev M123-dev Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@M123-dev M123-dev merged commit 5d4a883 into develop Feb 13, 2022
@M123-dev M123-dev deleted the image-picker-null-error branch February 13, 2022 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
image upload 🌐 l10n Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users. 🥫 Product page
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Null error when adding a photo and then going back without taking one
3 participants