mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-08-06 06:46:05 +08:00
updated readme of each example with a screenshot/gif and more details about the example.
added more comments to code
This commit is contained in:
@ -1,8 +1,12 @@
|
||||
# handling_routes
|
||||
# Handling Routes
|
||||
|
||||
Mobile apps typically reveal their contents via full-screen elements called "screens" or "pages". In Flutter these elements are called routes and they're managed by a Navigator widget. The navigator manages a stack of Route objects and provides methods for managing the stack, like Navigator.push and Navigator.pop.
|
||||
|
||||
Read [[Documentation](https://docs.flutter.io/flutter/widgets/Navigator-class.html)]
|
||||
|
||||
<img src="demo_img.gif" height="600em" />
|
||||
|
||||
A new Flutter project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For help getting started with Flutter, view our online
|
||||
[documentation](http://flutter.io/).
|
||||
For help getting started with Flutter, view online [documentation](http://flutter.io/).
|
BIN
handling_routes/demo_img.gif
Normal file
BIN
handling_routes/demo_img.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 540 KiB |
@ -4,28 +4,42 @@ class AboutPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
// AppBar
|
||||
appBar: new AppBar(
|
||||
// Title
|
||||
title: new Text("About Page"),
|
||||
// App Bar background color
|
||||
backgroundColor: Colors.blue,
|
||||
),
|
||||
// Body
|
||||
body: new Container(
|
||||
// Center the content
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
// Center content in the column
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
// add children to the column
|
||||
children: <Widget>[
|
||||
// Text
|
||||
new Text(
|
||||
"About Page\nClick on below icon to goto Home Page",
|
||||
// Setting the style for the Text
|
||||
style: new TextStyle(fontSize: 20.0),
|
||||
// Set text alignment to center
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
// Icon Button
|
||||
new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.home,
|
||||
color: Colors.blue,
|
||||
color: Colors.red,
|
||||
),
|
||||
// Execute when pressed
|
||||
onPressed: () {
|
||||
// use the navigator to goto a named route
|
||||
Navigator.of(context).pushNamed('/');
|
||||
},
|
||||
// Setting the size of icon
|
||||
iconSize: 80.0,
|
||||
)
|
||||
],
|
||||
|
@ -4,28 +4,42 @@ class HomePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
// AppBar
|
||||
appBar: new AppBar(
|
||||
// Title
|
||||
title: new Text("Home Page"),
|
||||
// App Bar background color
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
// Body
|
||||
body: new Container(
|
||||
// Center the content
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
// Center content in the column
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
// add children to the column
|
||||
children: <Widget>[
|
||||
// Text
|
||||
new Text(
|
||||
"Home Page\nClick on below icon to goto About Page",
|
||||
style: new TextStyle(fontSize: 20.0),
|
||||
// Setting the style for the Text
|
||||
style: new TextStyle(fontSize: 20.0,),
|
||||
// Set text alignment to center
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
// Icon Button
|
||||
new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.info,
|
||||
color: Colors.green,
|
||||
color: Colors.blue,
|
||||
),
|
||||
// Execute when pressed
|
||||
onPressed: () {
|
||||
// use the navigator to goto a named route
|
||||
Navigator.of(context).pushNamed('/about');
|
||||
},
|
||||
// Setting the size of icon
|
||||
iconSize: 80.0,
|
||||
)
|
||||
],
|
||||
|
Reference in New Issue
Block a user