You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
876 B
38 lines
876 B
import 'package:flutter/material.dart';
|
|
|
|
class AnimatedTranslate extends ImplicitlyAnimatedWidget {
|
|
final Widget? child;
|
|
final Offset? offset;
|
|
|
|
AnimatedTranslate({this.child, this.offset})
|
|
: super(
|
|
duration: Duration(milliseconds: 300),
|
|
);
|
|
|
|
@override
|
|
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState() =>
|
|
_AnimatedTranslateState();
|
|
}
|
|
|
|
class _AnimatedTranslateState
|
|
extends AnimatedWidgetBaseState<AnimatedTranslate> {
|
|
Tween<Offset?>? _offsetTween;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Transform.translate(
|
|
offset: _offsetTween!.evaluate(animation)!,
|
|
child: widget.child,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void forEachTween(visitor) {
|
|
_offsetTween = visitor(
|
|
_offsetTween,
|
|
widget.offset,
|
|
(value) => Tween<Offset>(begin: value),
|
|
) as Tween<Offset?>?;
|
|
}
|
|
}
|