Previous page animation freezes during route transition with GetMaterialApp
**Describe the bug**
When using `GetMaterialApp`, the previous (outgoing) page freezes/stops animating during a route transition. The incoming page slides in correctly, but the outgoing page should have a subtle animation (e.g., scale-down with `ZoomPageTransitionsBuilder`) — instead it remains completely static.
Replacing `GetMaterialApp` with Flutter's `MaterialApp` resolves the issue and the outgoing page animates correctly.
## Regression / Version-specific behavior
The scope of the issue differs across GetX versions:
| Version | `Get.to()` | `Navigator.push` |
| ------- | ---------- | ---------------- |
| **4.7.3** | ❌ Buggy | ✅ Works |
| **5.0.0-release-candidate-9.3.2** | ❌ Buggy | ❌ Buggy |
| **master (`7bfcd9c3`)** | ❌ Buggy | ❌ Buggy (same as 5.0.0-rc) |
- On **4.7.3**, the bug only manifests when using `Get.to()`. Using Flutter's native `Navigator.push` with `MaterialPageRoute` works correctly.
- Starting from **5.0.0-release-candidate-9.3.2**, the bug applies to both `Get.to()` and `Navigator.push`, meaning the issue has regressed further.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a new Flutter project.
2. Add `get` as a dependency.
3. Replace `MaterialApp` with `GetMaterialApp` in `main.dart`.
4. Set `timeDilation = 5.0` to make the animation slow enough to observe.
5. Configure `ZoomPageTransitionsBuilder` as the page transition builder.
6. Use `Navigator.push(context, MaterialPageRoute(builder: (context) => const NewPage()))` to navigate to a new page.
7. Observe that the previous page does not animate — it stays frozen while only the new page slides in.
**Reproduction code**
```dart
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
timeDilation = 5.0; // Slow down animations to observe the issue
return GetMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(),
},
),
),
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> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const NewPage()),
);
},
child: const Text("Go to new page"),
),
),
);
}
}
class NewPage extends StatelessWidget {
const NewPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("New page")),
body: Center(
child: TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Go back"),
),
),
);
}
}
```
**Expected behavior**
When `Navigator.push` is called, the previous (outgoing) page should have a transition animation (e.g., scale-down when using `ZoomPageTransitionsBuilder`), just as it does when using Flutter's plain `MaterialApp`. Both pages should animate simultaneously during the route transition.
**Actual behavior**
The previous page freezes immediately when the route transition begins and remains completely static until the transition completes. Only the incoming page animates.
**Additional context**
- This issue occurs because `GetMaterialApp` wraps the Navigator in a way that interferes with the route transition's "secondary" animation (the animation driving the outgoing page).
- The bug is reproducible on both Android and iOS.
- Using `Navigator.push` directly is a valid use case — users should not be forced to use `Get.to()` for correct route transitions.
**Flutter Version:**
3.41.7
**Getx Version:**
4.7.3, 5.0.0-release-candidate-9.3.2, master(7bfcd9)
0 条评论