-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Conversation
There was a problem hiding this 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 FutureBuilder
s. What about using LoadingDialog
?
- I'm on a page
- I click on a button that runs async code
- which opens a "running" dialog with "close" button
- and when the code is over, the dialog is automatically closed
- 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
final Uint8List? bytes = await LoadingDialog.run<Uint8List?>( | ||
context: context, | ||
future: pickImage(), | ||
title: appLocalizations.selecting_photo, | ||
); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
What
Fixes bug(s)