Skip to content

Instantly share code, notes, and snippets.

@igabice
Last active January 23, 2020 14:39
Show Gist options
  • Save igabice/888c7e4355c6e4cfc70c66664e68249b to your computer and use it in GitHub Desktop.
Save igabice/888c7e4355c6e4cfc70c66664e68249b to your computer and use it in GitHub Desktop.
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