Reputation: 339
I have Get.to() that will show webview after i clicked it
onPressed: () {
Navigator.of(context).pop(false);
Timer(
Duration(milliseconds: 350),
() => {
Get.to(
WebviewService(
urlName: action.name!,
urlPath: action.link!,
),
transition: Transition.fadeIn,
duration: Duration(milliseconds: 500),
)
},
);
},
but recently I want to add another conditional route, example: when I clicked on few exact item it will show the page_view.dart that consists native view instead of webview, and when I click on another item that had no view page it will show the webview. just like this:
if(x == page_view){
show page_view()
}else{
WebviewService(
urlName: action.name!,
urlPath: action.link!,
),
}
How to make that conditional Get.to()
Upvotes: 0
Views: 58
Reputation: 1583
AFAIK you want to make navigation that depend on the conditions.
But unfortunately you can't add conditions in GO.to
you need to perform condition checking before using of the GO.to
and pass exact route where do you want to navigate or you can make the condition in the GoRouter that you initialized in your app before.
You can think about the GO.to
as a trigger that triggers the navigation with parameters that you pass in.
Upvotes: 1