Skip to content

Instantly share code, notes, and snippets.

@rubgithub
Created March 23, 2020 12:54
Show Gist options
  • Save rubgithub/ab9606eb3dcfb378425154d977d59e11 to your computer and use it in GitHub Desktop.
Save rubgithub/ab9606eb3dcfb378425154d977d59e11 to your computer and use it in GitHub Desktop.
Navegação básica
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Navigation Basics',
home: FirstRoute(),
));
}
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('First Route'),
),
body: Center(
child: RaisedButton(
child: Text('Open route'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
},
),
),
);
}
}
class SecondRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: RaisedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Go back!'),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment