Skip to content

Commit

Permalink
Don't rebuild histogram unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Sep 17, 2024
1 parent e463f08 commit d0b51c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class _SlyEditorPageState extends State<SlyEditorPage> {

late final SlyImage _originalImage = widget.image;
late SlyImage _editedImage;
late Widget _histogram = getHistogram(_editedImage);

Uint8List? _originalImageData;
Uint8List? _editedImageData;
Expand Down Expand Up @@ -219,9 +220,13 @@ class _SlyEditorPageState extends State<SlyEditorPage> {
_saveOnLoad = false;
}

if (!mounted) return;
setState(() {
_histogram = getHistogram(_editedImage);
});

_editedImage.encode(format: 'JPEG75').then((data) {
if (!mounted) return;

setState(() {
_editedImageData = data;
});
Expand Down Expand Up @@ -1171,7 +1176,7 @@ class _SlyEditorPageState extends State<SlyEditorPage> {
child: SizedBox(
height: constraints.maxWidth > 600 ? 40 : 30,
width: constraints.maxWidth > 600 ? null : 150,
child: getHistogram(_editedImage),
child: _histogram,
),
)
: Container(),
Expand Down

0 comments on commit d0b51c4

Please sign in to comment.