Skip to content

Commit

Permalink
feat: Navigation between two pages using navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
dilumdesilva committed Jun 17, 2019
1 parent 4f15c9d commit c66e9a7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
3 changes: 2 additions & 1 deletion code_samples/simple_navigation/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:simple_navigation/page1.dart';

void main() => runApp(MyApp());

Expand All @@ -11,7 +12,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold()
home: Page1()
);
}
}
33 changes: 33 additions & 0 deletions code_samples/simple_navigation/lib/page1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:simple_navigation/page2.dart';

class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
backgroundColor: Colors.blue,
floatingActionButton: FloatingActionButton(
onPressed: (){
Navigator.push(context, new MaterialPageRoute(
builder: (context) => Page2()
));
},
tooltip:'Next Page',
child: IconTheme(
data: new IconThemeData(
color: Colors.blue,
),
child: new Icon(Icons.arrow_forward),
),
backgroundColor: Colors.white,
),
body: Container(
child: Center(
child: Text(
'Page One',
style: TextStyle(fontSize: 35.0, fontWeight: FontWeight.bold, color: Colors.white ),
),
)
),
);
}

30 changes: 30 additions & 0 deletions code_samples/simple_navigation/lib/page2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
backgroundColor: Colors.amber,
floatingActionButton: FloatingActionButton(
onPressed: (){
Navigator.pop(context);
},
tooltip:'Next Page',
child: IconTheme(
data: new IconThemeData(
color: Colors.blue,
),
child: new Icon(Icons.arrow_back),
),
backgroundColor: Colors.white,
),
body: Container(
child: Center(
child: Text(
'Page Two',
style: TextStyle(fontSize: 35.0, fontWeight: FontWeight.bold, color: Colors.white ),
),
)
),
);
}

0 comments on commit c66e9a7

Please sign in to comment.