Closed Gueztt closed 3 weeks ago
Found a way.
I got the flip and rotate right/left animation working but everything else started working unexpectedly. Help is needed to implement it in a proper way.
@Gueztt Could you provide what you've found
@Nico3652 Thank you for responding.
Following are the changes made to the existing:
extended_image_editor.dart
from :
Positioned.fill( child: image, ),
to:
Positioned.fill( child: AnimatedBuilder( animation: acontroller, child: Container( color: Colors.red, ), builder: (BuildContext context, Widget? child) { final Matrix4 transform = Matrix4.identity(); if (isFlip) { transform.setEntry(3, 2, 0.0002); transform.rotateY(animationY.value); } if (isRotate) { transform.rotateZ(animationZ.value); } return Transform( transform: transform, child: image, alignment: Alignment.center, ); }, ), ),
from:
void rotate({required bool right}) { if (_layerKey.currentState == null) { return; } setState(() { _editActionDetails!.rotate( right ? pi / 2.0 : -pi / 2.0, _layerKey.currentState!.layoutRect, BoxFit.contain, ); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); }); } void flip() { assert(_editActionDetails != null && _editorConfig != null); setState(() { _editActionDetails!.flip(); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); }); } void reset() { setState(() { _editorConfig = null; _editActionDetails = null; _initGestureConfig(); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); }); }
to:
void rotate({required bool right}) { if (_layerKey.currentState == null) { return; } setState(() { isFlip = false; isRotate = true; isRight = right; if (!acontroller.isAnimating) { _editActionDetails!.rotate( right ? pi / 2.0 : -pi / 2.0, _layerKey.currentState!.layoutRect, BoxFit.contain, ); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); } if (right == true) { if (!acontroller.isAnimating) { acontroller.reset(); acontroller.forward().whenComplete(() { aRotateValue = aRotateValue + (pi / 2); }); } } else if (right == false) { if (!acontroller.isAnimating) { acontroller.reset(); acontroller .forward() .whenComplete(() => aRotateValue = aRotateValue - (pi / 2)); } } }); } void flip() { assert(_editActionDetails != null && _editorConfig != null); setState(() { isFlip = true; isRotate = false; if (acontroller.status == AnimationStatus.completed) { acontroller.reverse(); } else { acontroller.forward(); } _editActionDetails!.flip(); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); }); } void reset() { setState(() { _editorConfig = null; _editActionDetails = null; _initGestureConfig(); _editorConfig!.editActionDetailsIsChanged?.call(_editActionDetails); aRotateValue = 0; acontroller.reset(); }); }
added following lines in the build method:
final Animation<double> animationY = Tween<double>(begin: 0, end: pi).animate(acontroller); final Animation<double> animationZ = isRight ? Tween<double>(begin: aRotateValue, end: aRotateValue + (pi / 2)) .animate(CurvedAnimation(parent: acontroller, curve: Curves.ease)) : Tween<double>(begin: aRotateValue, end: aRotateValue - (pi / 2)) .animate(CurvedAnimation(parent: acontroller, curve: Curves.ease));
extended_render_image.dart
Removed following lines of code :
if (editAction.hasRotateAngle) { result.multiply(Matrix4.rotationZ(editAction.rotateRadian)); } if (editAction.flipY) { result.multiply(Matrix4.rotationY(pi)); } if (editAction.flipX) { result.multiply(Matrix4.rotationX(pi)); }
What Works
What went crazy
what I have tried
I am new to flutter .
If you can help in this regard or point me in right direction I'll be grateful
@zmtzawqlp Any pointers for this, plz.
please update to lastest version
This is a great library. I just want some help as to how can we have animation while image is flipping. I could not find anything on the subject also I'm new at flutter.