Created
April 28, 2020 03:47
-
-
Save AlexV525/56204620b5b5518527a1b16556a92605 to your computer and use it in GitHub Desktop.
Flutter Hero Text Example.
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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
void pushToNext() { | |
Navigator.of(context).push( | |
MaterialPageRoute( | |
builder: (_) => Scaffold( | |
body: Align( | |
alignment: Alignment.topCenter, | |
child: Hero( | |
tag: 'Hero Text', | |
child: Text( | |
'Hero Text', | |
style: TextStyle(color: Colors.black, inherit: false), | |
), | |
), | |
), | |
), | |
), | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Hero( | |
tag: 'Hero Text', | |
child: Text( | |
'Hero Text', | |
style: TextStyle(color: Colors.black, inherit: false), | |
), | |
), | |
], | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: pushToNext, | |
tooltip: 'Increment', | |
child: Icon(Icons.add), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment