|
| 1 | +# Mockingjay — Deprecation Notice & Migration Guide |
| 2 | + |
| 3 | +> **This package is deprecated and is no longer actively maintained.** |
| 4 | +> The repository remains public and available for the community to fork. |
| 5 | +
|
| 6 | +--- |
| 7 | + |
| 8 | +## Why is Mockingjay being deprecated? |
| 9 | + |
| 10 | +Mockingjay provides mock classes for testing Flutter's **Navigator 1.0** (imperative) APIs. |
| 11 | +The Flutter ecosystem has broadly shifted toward **Navigator 2.0** — the declarative navigation API — |
| 12 | +and packages like [`go_router`](https://pub.dev/packages/go_router) have become the de facto standard |
| 13 | +for navigation in modern Flutter applications. |
| 14 | + |
| 15 | +Given this shift, maintaining Mockingjay no longer aligns with the current direction of the Flutter |
| 16 | +community. Rather than let it languish with infrequent updates, we are making the deprecation official |
| 17 | +so users can plan accordingly. |
| 18 | + |
| 19 | +The package will remain available on [pub.dev](https://pub.dev/packages/mockingjay) and the source |
| 20 | +code will stay public and available to fork. If there is enough community interest, anyone is welcome to create |
| 21 | +and maintain a community edition. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## What should I do if I'm using Mockingjay? |
| 26 | + |
| 27 | +You have two paths depending on how your app handles navigation: |
| 28 | + |
| 29 | +### Path 1 — Migrate to Navigator 2.0 (recommended) |
| 30 | + |
| 31 | +If you are building a new app or are willing to update your navigation layer, migrating to |
| 32 | +Navigator 2.0 is the recommended long-term path. |
| 33 | + |
| 34 | +1. **Adopt `go_router`** (or another Navigator 2.0-compatible package) for your app's routing. |
| 35 | + See the [go_router documentation](https://pub.dev/packages/go_router) to get started. |
| 36 | + |
| 37 | +2. **Update your tests.** With `go_router`, navigation is driven by a `GoRouter` instance. |
| 38 | + In tests, you can provide a mock router with a test-specific configuration and inject it as a `Provider` so you can access it through `BuildContext`: |
| 39 | + |
| 40 | + ```dart |
| 41 | + final router = GoRouter( |
| 42 | + initialLocation: '/', |
| 43 | + routes: [ |
| 44 | + GoRoute(path: '/', builder: (_, __) => const HomeScreen()), |
| 45 | + GoRoute(path: '/detail', builder: (_, __) => const DetailScreen()), |
| 46 | + ], |
| 47 | + ); |
| 48 | +
|
| 49 | + testWidgets('navigates to detail', (tester) async { |
| 50 | + await tester.pumpWidget(MaterialApp.router(routerConfig: router)); |
| 51 | + // Interact and assert normally |
| 52 | + }); |
| 53 | + ``` |
| 54 | + |
| 55 | +3. **Remove the `mockingjay` dependency** from your `pubspec.yaml` once all usages have been replaced. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### Path 2 — Continue using Navigator 1.0 (no migration) |
| 60 | + |
| 61 | +Navigator 1.0 is still part of Flutter and is not going away. If your project intentionally uses |
| 62 | +the imperative API and you rely on Mockingjay, you have two options: |
| 63 | + |
| 64 | +- **Fork the repository** and maintain your own copy. The source code is fully public under its |
| 65 | + existing license. |
| 66 | +- **Use `NavigatorObserver` and manual test doubles** as a lightweight alternative, which requires |
| 67 | + no third-party package. |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## Resources |
| 72 | + |
| 73 | +- [go_router on pub.dev](https://pub.dev/packages/go_router) |
| 74 | +- [Flutter Navigation & Routing docs](https://docs.flutter.dev/ui/navigation) |
| 75 | +- [Navigator 2.0 overview](https://medium.com/flutter/learning-flutters-new-navigation-and-routing-system-7c9068155ade) |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +Thank you to everyone who used and contributed to Mockingjay over the years. |
0 commit comments