get 1.7.1 get: ^1.7.1 copied to clipboard
A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars with no context.
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(MaterialApp(
title: 'Navigation Basics',
navigatorKey: Get.key,
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: () {
Get.to(SecondRoute());
},
),
),
);
}
}
class SecondRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: RaisedButton(
onPressed: () {
Get.back();
},
child: Text('Go back!'),
),
),
);
}
}