Code:
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 GridView2 extends StatefulWidget {
@override
_GridView2State createState() => _GridView2State();
}
class _GridView2State extends State<GridView2> {
@override
Widget build(BuildContext c) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('View Gridview Animation'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Grid2()),
);
},
),
),
);
}
}
class Grid2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
double _w = MediaQuery.of(context).size.width;
int columnCount = 3;
return Scaffold(
appBar: AppBar(
title: Text("Go Back"),
centerTitle: true,
brightness: Brightness.dark),
body: AnimationLimiter(
child: GridView.count(
physics:
BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
padding: EdgeInsets.all(_w / 60),
crossAxisCount: columnCount,
children: List.generate(
50,
(int index) {
return AnimationConfiguration.staggeredGrid(
position: index,
duration: Duration(milliseconds: 500),
columnCount: columnCount,
child: ScaleAnimation(
duration: Duration(milliseconds: 900),
curve: Curves.fastLinearToSlowEaseIn,
child: FadeInAnimation(
child: Container(
margin: EdgeInsets.only(
bottom: _w / 30, left: _w / 60, right: _w / 60),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 40,
spreadRadius: 10,
),
],
),
),
),
),
);
},
),
),
),
);
}
}
1 Comments
Cool
ReplyDelete