User gestures and back button are not working when using PageRouteBuilder - flutter

to achieve a fade transition I used a PageRouteBuilder()to build some of my routes.
I noticed however while testing the app that the back button on Android and The User gesture on IOS are not working to navigate back to previous route!
Is this the normal behavior of the PageRouteBuilder()? or am I maybe doing something wrong?
thanks a lot!

So as it turned out, in MaterialPageRoute() the PageTransitionBuilder is selected based on which platform the app is running on.
I was able to get it to work for Android by using the WillPopScope() widget, as I was using Nested Navigators.
However, on IOS for the back gesture they are using the private class _CupertinoBackGestureController and I don't think there is an easy way to achieve that at this moment!
Hope that helps whoever is facing the same thing and thanks again!

The popup to back button has nothing to do with PageRouteBuilder, but has something to do with how you are inserting the second page in the stack.
If you are using Navigator.pushNamed(context, <PageRouteBuilder>), this will keep the first page in the stack and the back button should work.
However, If you are using Navigator.pushNamedReplacement(context, <PageRouteBuilder>), it will remove the first page and push the second page to stack.

I'm currently experimenting with wrapping the page to be pushed in a GestureDetector, and then setting one of the onHorizontalDrag properties to pop the route. (I do this within the PageRouteBuilder itself, that way I can just pass in the page like normal when pushing.) This swipedetector package might replace the GestureDetector, or I might even experiment with this swipe_back_detector specifically made for custom routes made with PageRouteBuilder (see example they give).

Related

How to clear routing without moving to another page Flutter Getx

I can go to my page PgMain by a lot of way (end of action, logout, button go to menu, button back, system back button, etc.). I want clear my routing every time, where I open PgMain page. How to do it inside PgMain class, for example inside build method? As I said previously, I have a lot of ways to go to PgMain, and not at every case I can use Get.offAll() method
Use
Get.offAll(PgMain()); Get.off(PgMain());
whenever you navigate to PgMain page.

Flutter on tap not working on Html element view

The webpage I'm loading contains a HtmlElementView class which will load an URL. And I am having an action in app bar and when I am tapping on a option, It is not responding.
In the reference image the account settings option is clickable because it is outside the HtmlElementView but the others two options are not clickable because it is on top of the HtmlElementView. Help me with an solution for this.
There seems to be no in easy way of dealing with this in flutter.
So the best option is to use pub.dev/packages/pointer_interceptor
Thanks to #Pat9RB for finding this!

How to detect current timestamp when a user leaves a screen in Flutter

I'm working on a Chat application with Flutter, i need to detect the time and date when a user leaves the screen of a particular chat. In other words, I need a way to detect the actual time a user navigates from the chat screen to any other screen. Please is there any solution for this? I was able to find a plugin called Route Observer, but from what I've read in the documentation, it can't really solve my problem.
Any help would be greatly appreciated.
If you are using Navigator.push() to go to the chat screen, you can use the then() method which is called when you leave the screen i.e. pop the context.
Simply call DateTime.now().millisecondsSinceEpoch in the then() method.

Hero Widget does not work in case of a custom page route

I have created a custom Page Route to act as a bottom dialog inspired by the IOS action sheet popup, I have the Page route working perfectly, now what i want is a hero Transition between the my first route and the next Popup route.
I have created a dartPad demonstartion showing the problem => https://dartpad.dev/e79bd9adf6845857e0829ec6fe5a4a55
Let me know if there is anything else that you need from my end.
Thanks in advance.
From https://flutter.dev/docs/development/ui/animations/hero-animations
Use PopupRoutes is not support right now
Heroes fly from one PageRoute to another. Dialogs (displayed with showDialog(), for example), use PopupRoutes, which are not PageRoutes. At least for now, you can’t animate a hero to a Dialog. For further developments (and a possible workaround), watch this issue https://github.com/flutter/flutter/issues/10667.

How do you "Swipe to go back" in Ionic?

There's nothing in the docs about this.
I've just read a blog post on ionics website saying that it's possible to swipe to go back (like ios7) and I've seen the latest ng-conf where they talked about it as well, but nowhere to they mention on how to implement the damn thing.
No need to do a on-swipe-left. The latest version of Ionic provides this, and is defaults to true.
As for using this feature, you need to create multiple views, and then just swipe from left, it will take you back to previous view.
Ionic has built in gesture events.
Ex.
<div on-swipe-left="swipeleftAction()">
</div>
So I guess you could place on-swipe-left or on-swipe-right in your page container or div.
I have a function that handled removing an item from the array of items,
I programatically closed all options buttons by calling
$ionicListDelegate.closeOptionButtons();