Skip to content

Instantly share code, notes, and snippets.

@braulio94
Created February 21, 2018 17:39
Show Gist options
  • Save braulio94/490d875847ff94611312e75a082b1a6f to your computer and use it in GitHub Desktop.
Save braulio94/490d875847ff94611312e75a082b1a6f to your computer and use it in GitHub Desktop.
Example of navigation and route in flutter
import 'package:flutter/material.dart';
import 'package:test_app/other_page.dart';
void main() => runApp(
new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomePage(),
routes: routes,
));
var routes = <String, WidgetBuilder> {
OtherPage.routeNAme: (BuildContext context) => new OtherPage(),
};
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Flutter Navigator Demo'),
),
floatingActionButton: new FloatingActionButton(
onPressed: (){
Navigator.pushNamed(context, OtherPage.routeNAme);
},
child: new Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment