In this recipe, you will use the animations Container Transform:
- In the pubspec.yaml file, import the animations dependency:
dependencies:
flutter:
sdk: flutter
animations: ^2.0.0
- At the top of the dismissible.dart file, import the animations package:
import 'package:animations/animations.dart';
- In the dismissible.dart file, in the itembuilder of the ListView, wrap the Dismissible widget into an OpenContainer widget, in its closedBuilder parameter, as shown here:
return OpenContainer(
closedBuilder: (context, openContainer) {
return Dismissible(
key: Key(sweets[index]),
child: ListTile(
title: Text(sweets[index]),
trailing: Icon(Icons.cake),
onTap: () {
openContainer();
},
),
onDismissed: (direction) {
sweets.removeAt(index);
},
);
},);
- At the top of the OpenContainer object, add a transitionDuration and a transitionType, as shown here:
transitionDuration: Duration(seconds...