diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd6d1335c..12af7d50d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
-## [v1.8.4] - 2023-03-17
-
### Fixed
- permission confusion when removable volume changes
+- Viewer: flickering on first scale animation in some cases
+
+## [v1.8.4] - 2023-03-17
### Added
diff --git a/plugins/aves_magnifier/lib/src/controller/controller.dart b/plugins/aves_magnifier/lib/src/controller/controller.dart
index 3e1695375..89858643f 100644
--- a/plugins/aves_magnifier/lib/src/controller/controller.dart
+++ b/plugins/aves_magnifier/lib/src/controller/controller.dart
@@ -1,5 +1,4 @@
import 'dart:async';
-import 'dart:ui';
import 'package:aves_magnifier/src/controller/state.dart';
import 'package:aves_magnifier/src/scale/scale_boundaries.dart';
@@ -20,17 +19,13 @@ class AvesMagnifierController {
AvesMagnifierController({
MagnifierState? initialState,
}) : super() {
- initial = initialState ??
- const MagnifierState(
- position: Offset.zero,
- scale: null,
- source: ChangeSource.internal,
- );
+ const source = ChangeSource.internal;
+ initial = initialState ?? const MagnifierState(position: Offset.zero, scale: null, source: source);
previousState = initial;
_currentState = initial;
_setState(initial);
- const _initialScaleState = ScaleStateChange(state: ScaleState.initial, source: ChangeSource.internal);
+ const _initialScaleState = ScaleStateChange(state: ScaleState.initial, source: source);
previousScaleState = _initialScaleState;
_currentScaleState = _initialScaleState;
_setScaleState(_initialScaleState);
diff --git a/plugins/aves_magnifier/lib/src/controller/controller_delegate.dart b/plugins/aves_magnifier/lib/src/controller/controller_delegate.dart
index c2de57bbb..21b373790 100644
--- a/plugins/aves_magnifier/lib/src/controller/controller_delegate.dart
+++ b/plugins/aves_magnifier/lib/src/controller/controller_delegate.dart
@@ -80,15 +80,20 @@ mixin AvesMagnifierControllerDelegate on State {
Offset get position => controller.position;
+ double? recalcScale() {
+ final scaleState = controller.scaleState.state;
+ final newScale = controller.getScaleForScaleState(scaleState);
+ markNeedsScaleRecalc = false;
+ setScale(newScale, ChangeSource.internal);
+ return newScale;
+ }
+
double? get scale {
final scaleState = controller.scaleState.state;
final needsRecalc = markNeedsScaleRecalc && !(scaleState == ScaleState.zoomedIn || scaleState == ScaleState.zoomedOut);
final scaleExistsOnController = controller.scale != null;
if (needsRecalc || !scaleExistsOnController) {
- final newScale = controller.getScaleForScaleState(scaleState);
- markNeedsScaleRecalc = false;
- setScale(newScale, ChangeSource.internal);
- return newScale;
+ return recalcScale();
}
return controller.scale;
}
diff --git a/plugins/aves_magnifier/lib/src/core/core.dart b/plugins/aves_magnifier/lib/src/core/core.dart
index 58edae587..de9829584 100644
--- a/plugins/aves_magnifier/lib/src/core/core.dart
+++ b/plugins/aves_magnifier/lib/src/core/core.dart
@@ -72,6 +72,9 @@ class _MagnifierCoreState extends State with TickerProviderStateM
..addStatusListener(onAnimationStatus);
_positionAnimationController = AnimationController(vsync: this)..addListener(handlePositionAnimate);
_registerWidget(widget);
+ // force delegate scale computing on initialization
+ // so that it does not happen lazily at the beginning of a scale animation
+ recalcScale();
}
@override