import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
class ListView4 extends StatefulWidget {
@override
_ListView4State createState() => _ListView4State();
}
class _ListView4State extends State<ListView4> {
@override
Widget build(BuildContext c) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('View Listview Animation'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SlideAnimation4()),
);
},
),
),
);
}
}
class SlideAnimation4 extends StatelessWidget {
@override
Widget build(BuildContext context) {
double _w = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text("Go Back"),
centerTitle: true,
brightness: Brightness.dark,
),
body: AnimationLimiter(
child: ListView.builder(
padding: EdgeInsets.all(_w / 30),
physics:
BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
itemCount: 20,
itemBuilder: (BuildContext context, int index) {
return AnimationConfiguration.staggeredList(
position: index,
delay: Duration(milliseconds: 100),
child: SlideAnimation(
duration: Duration(milliseconds: 2500),
curve: Curves.fastLinearToSlowEaseIn,
child: FadeInAnimation(
curve: Curves.fastLinearToSlowEaseIn,
duration: Duration(milliseconds: 2500),
child: Container(
margin: EdgeInsets.only(bottom: _w / 20),
height: _w / 4,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 40,
spreadRadius: 10,
),
],
),
),
),
),
);
},
),
),
);
}
}