refactor: remove the get dependency#46
Open
ferrarafer wants to merge 4 commits into
Open
Conversation
Reimplements all services on native Flutter APIs and drops `get`: - NavigationService now uses the native Navigator through an owned GlobalKey<NavigatorState>, with a StackedRouting model and a StackedNavigationConfig (replacing Get.routing / Get.config). - Transitions are built with PageRouteBuilder (buildTransitionRoute). - StackObserver feeds StackedRouting using native route types only. - DialogService uses showGeneralDialog; BottomSheetService uses showModalBottomSheet; GetPlatform.isAndroid -> defaultTargetPlatform. - SnackbarService uses a vendored GetSnackBar widget + controller (MIT, attributed) hosted on the navigator overlay; SnackbarConfig is preserved so the public API is unchanged. - get removed from pubspec.yaml. Adds a behavioural test suite (navigation, dialog, bottom sheet, snackbar, observer, transitions) as a safety net for the migration. BREAKING: StackedService.navigatorKey is now an owned key (was Get.key). config(enableLog/defaultGlobalState), popGesture and the bottom sheet enter/exit durations are kept for compatibility but are now no-ops. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqYch1wfAZ5J9fGBh38AKU
FilledStacks
requested changes
Jun 22, 2026
FilledStacks
left a comment
Contributor
There was a problem hiding this comment.
Awesome @ferrarafer thanks for this addition.
Could you please update the example apps to use this, run the integration tests and see if it all passes please.
That should show us if the basics are still working.
Adds an integration_test suite that drives the example app end-to-end to verify the get-removal refactor's behaviour through the public API: - DialogService -> showGeneralDialog - SnackbarService -> vendored GetSnackBar on the navigator overlay - BottomSheetService -> showModalBottomSheet - NavigationService -> native Navigator + PageRouteBuilder transitions Each test dismisses its transient UI and settles before ending so the shared StackedService overlay/navigator tickers are disposed cleanly. Also adds the integration_test dev dependency + web driver entrypoint, and replaces deprecated MaterialStateProperty with WidgetStateProperty in setup_bottom_sheet_ui.dart so the example analyzes clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QX2hw8ST4QPV8DpockczFm
The example's Android scaffolding (Gradle 5.6.2, AGP 7, jcenter, legacy plugin loader) couldn't build under JDK 21, and iOS lacked the RunnerTests XCTest target that on-device integration tests require. Regenerated both platforms via `flutter create` and finished the migration by hand: Android: - Kotlin-DSL build files (settings/app/root build.gradle.kts), AGP 9.0.1, Gradle wrapper 9.1.0, mavenCentral. - Removed stale Groovy build files and the old com.example.example MainActivity package. - gradle.properties aligned to the current template (dropped obsolete enableR8/enableJetifier). - Manifests: dropped the AGP-incompatible package= attribute and added android:exported on the launcher activity. iOS: - Regenerated the Runner project with the RunnerTests target wired into project.pbxproj (flutter create won't inject it into an existing project), plus the modern UIScene embedding (SceneDelegate) and Podfile. App/bundle id is now com.example.stacked_services_example. Verified: migration_smoke_test passes on the Android emulator and the iOS simulator (DialogService, SnackbarService, BottomSheetService, NavigationService), and `flutter analyze` is clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QX2hw8ST4QPV8DpockczFm
Contributor
Author
|
Validated against the example apps in Stacked-Org/stacked#1191. Both |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CSHtjk6H5yhz977P7YXgPM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
getdependency fromstacked_services, reimplementing every service on native Flutter APIs. The public API of the services is preserved.The migration was done in phases, each verified green against a behavioural test suite added up front as a safety net:
NavigationServicenow uses the nativeNavigatorthrough an ownedGlobalKey<NavigatorState>. NewStackedRoutingmodel +StackedNavigationConfigreplaceGet.routing/Get.config. Transitions are built withPageRouteBuilder(buildTransitionRoute).StackObserverfeedsStackedRoutingusing native route types only.Get.dialog/Get.generalDialog→showGeneralDialog;GetPlatform.isAndroid→defaultTargetPlatform.Get.bottomSheet→showModalBottomSheet.GetSnackBarwidget + controller vendored intolib/src/snackbar/vendored/(MIT, attributed), hosted on the navigator overlay.SnackbarConfigis unchanged.getremoved.Why
Drops a heavy, monolithic dependency in favour of native Flutter, improving WASM compatibility and aligning with Stacked's existing
auto_route-based direction. No third-party replacement is introduced.Tests
New behavioural suite (43 tests, all green): navigation, dialog, bottom sheet, snackbar, route observer, transitions, and
StackedService. The tests reference only the public surface, so they passed against thegetimplementation and continue to pass after removal.flutter analyzeis clean except 2 pre-existing@requiredinfos.StackedService.navigatorKeyis now an ownedGlobalKey<NavigatorState>instead ofGet.key.NavigationService.config'senableLoganddefaultGlobalStateare now no-ops.popGestureand the bottom sheetenterBottomSheetDuration/exitBottomSheetDurationare kept for compatibility but are currently no-ops.Suggest releasing as a major version.
🤖 Generated with Claude Code