79376569

Date: 2025-01-22 05:05:52
Score: 0.5
Natty:
Report link

Use didPopRoute to handle back button:

@override
Future<bool> didPopRoute() {
  bool shouldAllowBack = true; // Update condition if required
  if (shouldAllowBack) {
    return super.didPopRoute(); // allow back
  } else {
    // Add logic here if required
    return Future.value(true);  // back not allowed
  }
}

& It works fine with GoRouter.

Exact code:

@override
Future<bool> didPopRoute() {
  return Future.value(true);
}

Official Documentaion:
Flutter > widgets.dart > WidgetsBindingObserver > didPopRoute method

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: ankushlokhande