Route Navigation for Unnamed Routes in GetX
import "package:firebase/GetX/HomeScreen.dart";
import "package:flutter/material.dart";
import "package:get/get.dart";
void main()
{
runApp(const MyApp());
}
class MyApp extends StatelessWidget
{
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: "Route Navigation for Unnamed Routes",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const GetXDemo(),
);
}
}
class GetXDemo extends StatelessWidget
{
const GetXDemo({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("GetX Route Navigation for Unnamed Routes"),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () async {
// Get.to(() {
// return HomeScreen();
// },
// /// To make the full screen Dialog
// fullscreenDialog: true,
// /// To provide animations
// // transition: Transition.zoom,
// /// Duration for transition animation
// // duration: const Duration(milliseconds: 4000),
// /// Curve Animation
// // curve: Curves.bounceInOut,
// );
///Go to home screen but no option to return to previous screen
// Get.off(() {
// return HomeScreen();
// },);
/// Go to home screen and cancel all previous screens/routes
// Get.offAll(() {
// return HomeScreen();
// },);
/// Go to next screen with some data
// Get.to(() {
// return HomeScreen();
// }, arguments: "Data from main");
/// Go to next screen and receive data sent from Home Screen
var data = await Get.to(() { return HomeScreen(); },);
print("The Received data is : $data");
},
child: const Text("Go to Home Screen"),
),
],
),
),
);
}
}
Comments
Post a Comment