Last active
January 23, 2020 14:39
-
-
Save igabice/888c7e4355c6e4cfc70c66664e68249b to your computer and use it in GitHub Desktop.
This file contains 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 Route Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: FirstPage(), | |
// Initially display FirstPage | |
); | |
} | |
} | |
class FirstPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Routing App'), | |
), | |
body: Center( | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
Text( | |
'First Page', | |
style: TextStyle(fontSize: 50), | |
), | |
RaisedButton( | |
child: Text('Go to second'), | |
onPressed: () { | |
Navigator.pushNamed(context, '/second', arguments: 'Hello World!'); | |
}, | |
) | |
], | |
), | |
), | |
); | |
} | |
} | |
class SecondPage extends StatelessWidget { | |
final String data; | |
SecondPage(this.data); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Routing App'), | |
), | |
body: Center( | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
Text( | |
'Second Page', | |
style: TextStyle(fontSize: 50), | |
), | |
Text( | |
data, | |
style: TextStyle(fontSize: 30), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment