Skip to content

Commit 10c5b58

Browse files
committed
animated list one
1 parent d0805a1 commit 10c5b58

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The code for Springy Widget is taken and refactored from (https://github.com/mat
132132

133133
## Animations
134134

135-
<img src="screenshots/animated_bottom_nav.gif" height="480px" > <img src="screenshots/anim3.gif" height="480px" > <img src="screenshots/animation2.gif" height="480px" > <img src="screenshots/animation1.gif" height="480px" >
135+
<img src="screenshots/anim5.gif" height="480px" > <img src="screenshots/animated_bottom_nav.gif" height="480px" > <img src="screenshots/anim3.gif" height="480px" > <img src="screenshots/animation2.gif" height="480px" > <img src="screenshots/animation1.gif" height="480px" >
136136

137137
## Ecommerce
138138

lib/core/presentation/routes.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import 'package:flutter/material.dart';
33
import 'package:flutter_ui_challenges/core/data/models/menu.dart';
44
import 'package:flutter_ui_challenges/src/pages/animations/anim4.dart';
5+
import 'package:flutter_ui_challenges/src/pages/animations/anim5.dart';
56
import 'package:flutter_ui_challenges/src/pages/bike/bike_details.dart';
67
import 'package:flutter_ui_challenges/src/pages/bike/home_page.dart';
78
import 'package:flutter_ui_challenges/src/pages/blog/sports_news1.dart';
@@ -102,6 +103,8 @@ final List<dynamic> pages = [
102103
path: AnimationTwoPage.path),
103104
SubMenuItem("Animated Bottom Bar", AnimatedBottomBar(),
104105
path: AnimatedBottomBar.path),
106+
SubMenuItem("Animated List One", AnimatedListOnePage(),
107+
path: AnimatedListOnePage.path),
105108
]),
106109
MenuItem(title: "Profile", icon: Icons.person, items: [
107110
SubMenuItem("Profile One", ProfileOnePage(), path: ProfileOnePage.path),

lib/src/pages/animations/anim5.dart

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* Author: Damodar Lohani
3+
* profile: https://github.com/lohanidamodar
4+
*/
5+
6+
import 'package:flutter/material.dart';
7+
import 'package:flutter_ui_challenges/src/pages/bike/bike_details.dart';
8+
9+
List<String> places = [
10+
"Nuwakot",
11+
"Dhaulagiri",
12+
"Rara",
13+
"Muktinath",
14+
"Pashupatinath"
15+
];
16+
17+
class AnimatedListOnePage extends StatefulWidget {
18+
static final String path = "lib/src/pages/animations/anim5.dart";
19+
@override
20+
_AnimatedListOnePageState createState() => _AnimatedListOnePageState();
21+
}
22+
23+
class _AnimatedListOnePageState extends State<AnimatedListOnePage> {
24+
List<String> items;
25+
GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
26+
27+
@override
28+
void initState() {
29+
items = ["Kathmandu", "Bhaktapur", "Pokhara", "Mount Everest"];
30+
super.initState();
31+
}
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Scaffold(
36+
appBar: AppBar(
37+
title: Text("Animated List One"),
38+
),
39+
backgroundColor: Colors.grey.shade300,
40+
body: AnimatedList(
41+
key: _listKey,
42+
initialItemCount: items.length,
43+
itemBuilder: (context, index, anim) {
44+
return SlideTransition(
45+
position: Tween<Offset>(begin: Offset(1, 0), end: Offset.zero)
46+
.animate(anim),
47+
child: BorderedContainer(
48+
margin: const EdgeInsets.symmetric(
49+
vertical: 4.0,
50+
horizontal: 8.0,
51+
),
52+
padding: const EdgeInsets.all(0),
53+
child: ListTile(
54+
title: Text(items[index]),
55+
trailing: IconButton(
56+
icon: Icon(Icons.clear),
57+
onPressed: () {
58+
_listKey.currentState.removeItem(index,
59+
(context, animation) {
60+
String removedItem = items.removeAt(index);
61+
return SizeTransition(
62+
sizeFactor: animation,
63+
axis: Axis.vertical,
64+
child: BorderedContainer(
65+
margin: const EdgeInsets.symmetric(
66+
vertical: 4.0,
67+
horizontal: 8.0,
68+
),
69+
padding: const EdgeInsets.all(0),
70+
child: ListTile(
71+
title: Text(removedItem),
72+
)),
73+
);
74+
});
75+
setState(() {});
76+
},
77+
),
78+
),
79+
),
80+
);
81+
},
82+
),
83+
floatingActionButton: FloatingActionButton(
84+
child: Icon(Icons.add),
85+
onPressed: () {
86+
places.shuffle();
87+
items.insert(items.length, places[0]);
88+
_listKey.currentState.insertItem(items.length - 1);
89+
setState(() {});
90+
},
91+
),
92+
);
93+
}
94+
}

screenshots/anim5.gif

1.86 MB
Loading

0 commit comments

Comments
 (0)