I'm trying to create the animation below, in which there is widget behind the Container.
I tried to use the class Dismissible but its animation does not stop at a certain point, it goes to the end and disappears with the item, according to the gif below:
I inserted the code into the SlideTransition class but I'm not sure how to integrate the onHorizontalDragStart, onHorizontalDragUpdate, onHorizontalDragEnd to generate the expected effect with the hidden back widget.
Could you help me solve the problem?
Follow the code below along with your screen:
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
AnimationController _controller;
Animation<double> _animation;
bool _dragUnderway = false;
@override
void initState() {
_controller = new AnimationController(
vsync: this,
duration: const Duration(milliseconds: 200),
);
_animation = new CurvedAnimation(
parent: _controller,
curve: new Interval(0.0, 1.0, curve: Curves.linear),
);
_controller.reverse();
super.initState();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(),
body: new Center(
child: new GestureDetector(
//onHorizontalDragStart: ,
//onHorizontalDragUpdate:,
//onHorizontalDragEnd: ,
child: new SlideTransition(
position: new Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.0, 0.0),
).animate(_animation),
child: new Container(
decoration: new BoxDecoration(
border: new Border(
top: new BorderSide(style: BorderStyle.solid, color: Colors.black26),
bottom: new BorderSide(style: BorderStyle.solid, color: Colors.black26),
)
),
padding: new EdgeInsets.only(top: 20.0, bottom: 20.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text('foo'),
],
),
),
)
)
),
);
}
}



