I am using named navigators for navigation. I set the default Transition to Transition.rightToLeft
. Now the problem is when I navigate from /tasklist
to /taskdetails
page, The transition is good. But when I get back from /taskdetails
to /tasklist
, The transition is still Transition.rightToLeft
. But I want the transition to be Transition.leftToRight
. How do I achive this?. I can't use the Get.back()
. Because the List of task in the /tasklist
page is not getting refreshed. So, I am using Get.offNamed()
to get back from /taskdetails
to /tasklist
.
Main Function:
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
GetMaterialApp(
home: const SplashScreen(),
getPages: [
GetPage(
name: "/login",
page: () => CommonBottomNavigationBar(
itemList: const [
LoginScreen(),
LoginScreen(),
LoginScreen(),
LoginScreen(),
],
onWillPop: () async {
return false;
},
),
),
GetPage(
name: "/tasklist",
page: () => CommonBottomNavigationBar(
itemList: const [
TaskListPage(),
TaskListPage(),
NotificationPage(),
ProfilePage(),
],
onWillPop: () async {
return false;
},
),
),
GetPage(
name: "/taskdetails",
page: () => CommonBottomNavigationBar(
title: "${Get.arguments["bookingId"]}",
onPressed: () => Get.offNamed("/tasklist"),
onWillPop: () async {
Get.offNamed("/tasklist");
return true;
},
itemList: const [
TaskDetailsPage(),
TaskDetailsPage(),
NotificationPage(),
ProfilePage(),
],
),
),
],
theme: ThemeData(
fontFamily: "AvenirLTDStd",
appBarTheme: const AppBarTheme(backgroundColor: kWhite),
primaryColor: kOrange,
primarySwatch: Colors.red,
applyElevationOverlayColor: true,
hoverColor: Colors.transparent,
splashColor: Colors.transparent,
),
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale("de", "DE"),
Locale("en", "US"),
Locale("fr", "FR"),
Locale("nl", "NL"),
Locale("pt-br", "pt-BR"),
],
enableLog: true,
defaultTransition: Transition.rightToLeft,
transitionDuration: const Duration(milliseconds: 500),
debugShowCheckedModeBanner: false,
),
);
}
Task List Page:
class TaskListPage extends GetView {
const TaskListPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return UpgradeAlert(
upgrader: Upgrader(
showIgnore: false,
showLater: false,
showReleaseNotes: false,
minAppVersion: "1.0.0",
messages: UpgraderMessages(code: kLanguageCode.value),
dialogStyle: Platform.isAndroid
? UpgradeDialogStyle.material
: UpgradeDialogStyle.cupertino,
platform:
Platform.isAndroid ? TargetPlatform.android : TargetPlatform.iOS,
willDisplayUpgrade: (
{appStoreVersion,
required display,
installedVersion,
minAppVersion}) async {
if (appStoreVersion != installedVersion) {
display = true;
} else {
display = false;
}
},
onUpdate: () => true,
),
child: Column(
children: [
TabBar(
tabs: taskListViewModel.tabBarList,
controller: taskListViewModel.tabBarController,
unselectedLabelStyle: const TextStyle(
color: kBlack, fontWeight: FontWeight.bold, fontSize: 18),
labelStyle: const TextStyle(
color: kBlack, fontWeight: FontWeight.bold, fontSize: 18),
),
Expanded(
child: TabBarView(
controller: taskListViewModel.tabBarController,
children: const [
RequestedTaskList(),
BookedTaskList(),
CompletedTaskList(),
],
),
),
],
),
);
}
}
Task Detail Page:
class TaskDetailsPage extends GetView {
const TaskDetailsPage({
Key? key
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetBuilder<TaskDetailsViewModel>(
init: TaskDetailsViewModel(),
builder: (taskDetailsViewModel) {
return Column(
children: [
SizedBox(
width: kWidth,
height: kHeight * 0.07,
child: TabBar(
controller: taskDetailsViewModel.tabBarController,
tabs: taskDetailsViewModel.tabBarList),
),
Expanded(
child: Obx(
() => taskDetailsViewModel.pageLoading.value
? const CommonCircularProgressIndicator()
: TabBarView(
controller: taskDetailsViewModel.tabBarController,
children: [
ListView(
shrinkWrap: true,
children: [
Card(
margin:
const EdgeInsets.symmetric(vertical: 10),
elevation: 2,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5, horizontal: 10),
child: Obx(
() => CommonText(
text: kLanguageList!
.value.taskAddress.obs,
size: 1,
boldText: true,
),
),
),
),
],
),
Padding(
padding: const EdgeInsets.all(10.0),
child: SingleChildScrollView(
child: Obx(
() => CommonText(
text: kLanguageList!
.value.taskerEarninig.obs,
size: 1.5,
boldText: true,
textColor: kBlack,
),
),
),
),
],
),
),
),
],
);
},
);
}
}