Repository: flutter
Issue: Swipe back gesture not smooth when pushing CupertinoPageRoute over a PageRouterBuilder
Labels: framework,f: cupertino,f: routes,a: quality,f: gestures,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.27,found in release: 3.28

### Steps to reproduce

When I open a CupertinoPageRoute from a custom page route, the manual swipe gesture for navigating back doesn’t work properly. I created a minimal reproduction that demonstrates the behavior when opening a CupertinoPageRoute from another CupertinoPageRoute and what happens when opening it from a custom route.

I've attached a video.
from 00:00 - 00:25 you can see the expected behavior, after that I show the bug.

### Expected results

The swipe back animation should be as smooth as the Cupertino->Cupertino case.


### Actual results

Custom page route -> Cupertino not smooth

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  void bugReproduction() {
    Navigator.of(context).push(
      PageRouteBuilder(
        pageBuilder: (context, animation, secondaryAnimation) {
          return Scaffold(
            appBar: AppBar(
              title: const Text('Custom Route Page'),
            ),
            body: Center(
              child: ElevatedButton(
                onPressed: () {
                  Navigator.of(context).push(
                    CupertinoPageRoute(
                      builder: (context) => const Scaffold(
                        body: Center(
                          child: Text('Cupertino Route Page'),
                        ),
                      ),
                    ),
                  );
                },
                child: const Text('Push Cupertino Route'),
              ),
            ),
          );
        },
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          return FadeTransition(
            opacity: animation,
            child: child,
          );
        },
      ),
    );
  }

  void okReproduction() {
    Navigator.of(context).push(
      CupertinoPageRoute(
        builder: (
          context,
        ) {
          return Scaffold(
            appBar: AppBar(
              title: const Text('Custom Route Page'),
            ),
            body: Center(
              child: ElevatedButton(
                onPressed: () {
                  Navigator.of(context).push(
                    CupertinoPageRoute(
                      builder: (context) => const Scaffold(
                        body: Center(
                          child: Text('Cupertino Route Page'),
                        ),
                      ),
                    ),
                  );
                },
                child: const Text('Push Cupertino Route'),
              ),
            ),
          );
        },
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
          child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        ElevatedButton(
          child: const Text("Custom route -> Cupertino route"),
          onPressed: () {
            bugReproduction();
          },
        ),
        ElevatedButton(
          child: const Text("Cupertino route -> Cupertino route"),
          onPressed: () {
            okReproduction();
          },
        ),
      ])),
      floatingActionButton: FloatingActionButton(
        onPressed: bugReproduction,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/467c95e1-659b-4c29-abab-b8ae0657c931

</details>




### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (13 days ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2
```

</details>