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.
36 lines
849 B
36 lines
849 B
4 years ago
|
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),
|
||
|
);
|
||
|
}
|
||
|
}
|