AnimationParam class
advanced usage:
SmartDialog.show(
animationTime: const Duration(milliseconds: 3000),
animationBuilder: (
AnimationController controller,
Widget child,
AnimationParam animationParam,
) {
return CustomAnimation(child: child, animationParam: animationParam);
},
builder: (_) {
return Container(
color: Colors.white,
padding: const EdgeInsets.all(30),
child: const Text('custom animation dialog'),
);
},
);
class CustomAnimation extends StatefulWidget {
const CustomAnimation({
Key? key,
required this.child,
required this.animationParam,
}) : super(key: key);
final Widget child;
final AnimationParam animationParam;
@override
State<CustomAnimation> createState() => _CustomAnimationState();
}
class _CustomAnimationState extends State<CustomAnimation>
with TickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: widget.animationParam.animationTime,
);
widget.animationParam.onForward = () {
_controller.value = 0;
_controller.forward();
};
widget.animationParam.onDismiss = () {
_controller.reverse();
};
super.initState();
}
@override
Widget build(BuildContext context) {
return RotationTransition(
turns: CurvedAnimation(parent: _controller, curve: Curves.elasticIn),
child: widget.child,
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}
Constructors
- AnimationParam({required Alignment alignment, required Duration animationTime, VoidCallback? onForward, VoidCallback? onDismiss})
Properties
- alignment ↔ Alignment
-
showXxx#alignment
getter/setter pair
- animationTime ↔ Duration
-
showXxx#animationTime
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- onDismiss ↔ VoidCallback?
-
The animation end callback, indicates that the dialog is about to close,
if you use custom or multiple AnimationController, you should use reverse() in this callback to reverse the animation
getter/setter pair
- onForward ↔ VoidCallback?
-
The animation starts callback, indicating that the dialog is about to open;
if you use custom or multiple AnimationControllers, the animation should be run using forward() in this callback
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited