Skip to content

Commit edd51ef

Browse files
committed
Example of working animations with key
1 parent c19aef9 commit edd51ef

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/animations/example/lib/shared_axis_transition.dart‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class _SharedAxisTransitionDemoState extends State<SharedAxisTransitionDemo> {
1717
SharedAxisTransitionType _transitionType =
1818
SharedAxisTransitionType.horizontal;
1919
bool _isLoggedIn = false;
20+
final GlobalKey pageKey = GlobalKey();
2021

2122
void _updateTransitionType(SharedAxisTransitionType newType) {
2223
setState(() {
@@ -54,7 +55,7 @@ class _SharedAxisTransitionDemoState extends State<SharedAxisTransitionDemo> {
5455
transitionType: _transitionType,
5556
);
5657
},
57-
child: _isLoggedIn ? _CoursePage() : _SignInPage(),
58+
child: _isLoggedIn ? _CoursePage(key: pageKey) : _SignInPage(),
5859
),
5960
),
6061
Padding(
@@ -115,6 +116,8 @@ class _SharedAxisTransitionDemoState extends State<SharedAxisTransitionDemo> {
115116
}
116117

117118
class _CoursePage extends StatelessWidget {
119+
const _CoursePage({ Key key }) : super(key: key);
120+
118121
@override
119122
Widget build(BuildContext context) {
120123
return ListView(
@@ -169,7 +172,13 @@ class _CourseSwitchState extends State<_CourseSwitch> {
169172
Widget build(BuildContext context) {
170173
final String subtitle = _value ? 'Bundled' : 'Shown Individually';
171174
return SwitchListTile(
172-
title: Text(widget.course),
175+
title: Row(
176+
children: <Widget>[
177+
const CircularProgressIndicator(),
178+
const Padding(padding: EdgeInsets.symmetric(horizontal: 4.0)),
179+
Text(widget.course),
180+
],
181+
),
173182
subtitle: Text(subtitle),
174183
value: _value,
175184
onChanged: (bool newValue) {

0 commit comments

Comments
 (0)