Repository: flutter
Issue: [go_router] `redirect` provides state with `fullPath` from the bottom of the navigation stack when using `refreshListenable`
Labels: package,has reproducible steps,P2,p: go_router,team-go_router,triaged-go_router,found in release: 3.13,found in release: 3.14

### Is there an existing issue for this?

- [X] I have searched the [existing package issues](https://github.com/flutter/flutter/issues?q=is%3Aopen+is%3Aissue+label%3Apackage)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### What package does this bug report belong to?

go_router

### What target platforms are you seeing this bug on?

Android, iOS

### Have you already upgraded your packages?

Yes

### Steps to reproduce

1. Run the app using attached code.
2. Tap on "Push second route" text to push another route on the stack.
3. Tap on "Add listenable event" text.
4. Observe console output. You can also put a breakpoint on print statement in the callback passed to `redirect` parameter.

I noticed the issue in `go_router` versions `10.1.2` and `9.0.0`, it worked fine in `7.0.0`, though.

### Expected results

`state` property in `redirect` callback  should provide path to the route that's on the top of the navigation stack. This happens when you push a new route programmatically, but does not happen when `redirect` callback gets triggered because `refreshListenable`'s value has changed.

### Actual results

`state` property in `redirect` callback provides path to the route that's at the bottom of the navigation stack.

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  runApp(
    MaterialApp.router(
      routerConfig: GoRouter(
        initialLocation: firstRoute.path,
        refreshListenable: _notifier,
        redirect: (context, state) {
          print(state.fullPath);
          return null;
        },
        routes: [
          firstRoute,
          secondRoute,
        ],
      ),
    ),
  );
}

final firstRoute = GoRoute(
  path: '/first',
  builder: (_, __) => const FirstRouteWidget(),
);
final secondRoute = GoRoute(
  path: '/second',
  builder: (_, __) => const SecondRouteWidget(),
);

final _notifier = ValueNotifier(true);

class FirstRouteWidget extends StatelessWidget {
  const FirstRouteWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: GestureDetector(
          onTap: () => context.push(secondRoute.path),
          child: const Text(
            'Push second route',
            style: TextStyle(fontSize: 30),
          ),
        ),
      ),
    );
  }
}

class SecondRouteWidget extends StatelessWidget {
  const SecondRouteWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: GestureDetector(
          onTap: () => _notifier.value = !_notifier.value,
          child: const Text(
            'Add listenable event',
            style: TextStyle(fontSize: 30),
          ),
        ),
      ),
    );
  }
}
```

</details>

### Logs

<details><summary>Logs</summary>

This is the output from the code sample, following the steps described above.

```console
flutter: /first  // first route being built
flutter: /second  // second route being built after navigating to it
flutter: /first  // redirect triggered by refreshListenable, should probably be: /second
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.3 22E252 darwin-arm64, locale en-PL)
    • Flutter version 3.13.0 on channel stable at /Users/paweljakubowski/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (3 weeks ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/paweljakubowski/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = /Users/paweljakubowski/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (3 available)
    • SM A405FN (mobile) • R58MC3WTRNJ • android-arm64  • Android 11 (API 30)
    • macOS (desktop)    • macos       • darwin-arm64   • macOS 13.3 22E252 darwin-arm64
    • Chrome (web)       • chrome      • web-javascript • Google Chrome 116.0.5845.140

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>