Created
November 26, 2019 19:25
-
-
Save agreensh/6240ea72f90cfda7c870867666713271 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:morpheus/morpheus.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| // This widget is the root of your application. | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| title: 'Bet App', | |
| theme: ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: MyList(), | |
| ); | |
| } | |
| } | |
| class MyList extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: | |
| Text('Morpheus Transition', style: TextStyle(color: Colors.white)), | |
| ), | |
| body: Column( | |
| children: [ | |
| Padding( | |
| padding: const EdgeInsets.all(8.0), | |
| child: Text('Select an item from the list below!'), | |
| ), | |
| Expanded( | |
| child: ListView.builder( | |
| itemCount: 20, | |
| itemBuilder: (context, index) { | |
| final _parentKey = GlobalKey(); | |
| return Card( | |
| elevation: 4, | |
| child: ListTile( | |
| key: _parentKey, | |
| leading: Hero( | |
| tag: "hero_$index", | |
| child: CircleAvatar( | |
| child: Text( | |
| (index + 1).toString(), | |
| ), | |
| ), | |
| ), | |
| title: Text('Item ${index + 1}'), | |
| onTap: () => _handleTap(context, _parentKey, index), | |
| ), | |
| ); | |
| }, | |
| ), | |
| ), | |
| ], | |
| ), | |
| ); | |
| } | |
| void _handleTap(BuildContext context, GlobalKey parentKey, int index) { | |
| Navigator.of(context).push( | |
| MorpheusPageRoute( | |
| builder: (context) => MyPage(index), | |
| parentKey: parentKey, | |
| ), | |
| ); | |
| } | |
| } | |
| class MyPage extends StatelessWidget { | |
| final int index; | |
| MyPage(this.index); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| backgroundColor: Colors.pink, | |
| title: Text('From a Morpheus Transition', | |
| style: TextStyle(color: Colors.white)), | |
| ), | |
| body: Hero( | |
| tag: "hero_$index", | |
| child: Padding( | |
| padding: const EdgeInsets.all(16.0), | |
| child: CircleAvatar( | |
| backgroundColor: Colors.pink, | |
| child: Text( | |
| (index + 1).toString(), | |
| style: TextStyle(color: Colors.white), | |
| ), | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment