Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report Getx5 : Error when setting URL strategy in GetMaterialApp #3224

Open
ironfactory8684 opened this issue Sep 26, 2024 · 1 comment
Assignees

Comments

@ironfactory8684
Copy link

ironfactory8684 commented Sep 26, 2024

After updating to the latest getx5 version, I encountered an error related to setting the URL strategy while using GetMaterialApp in a Flutter web project. The error occurs during the app initialization, stating that the URL strategy cannot be set a second time or after the app has already been initialized.

Error Message

======== Exception caught by widgets library =======================================================
The following assertion was thrown building GetMaterialApp:
Assertion failed: org-dartlang-sdk:///lib/ui_web/ui_web/navigation/url_strategy.dart:53:5
_customUrlStrategyCanBeSet
"Cannot set URL strategy a second time or after the app has been initialized."

Stack Trace

The relevant error-causing widget was: 
  GetMaterialApp GetMaterialApp:file:///Users/jepiloseu/StudioProjects/venustalk/lib/main.dart:204:16
When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3   assertFailed
lib/ui_web/ui_web/navigation/url_strategy.dart 53:5                          set urlStrategy
packages/flutter_web_plugins/src/navigation/url_strategy.dart 22:10          setUrlStrategy
packages/get/get_navigation/src/routes/url_strategy/impl/web_url.dart 4:3    removeHash
packages/get/get_navigation/src/routes/url_strategy/url_strategy.dart 6:3    setUrlStrategy
packages/get/get_navigation/src/routes/get_router_delegate.dart 100:46       new
packages/get/get_navigation/src/routes/get_router_delegate.dart 25:12        createDelegate
packages/get/get_navigation/src/root/get_root.dart 367:39                    onInit
packages/get/get_navigation/src/root/get_root.dart 331:5                     initState

Additional Information
Flutter version: 3.24.1
GetX version: ^5.0.0-release-candidate-9.2.1
Platform: Web
Is there a recommended solution for ensuring the URL strategy is set correctly in GetMaterialApp for Flutter web?

@ironfactory8684 ironfactory8684 changed the title Bug Report: Error when setting URL strategy in GetMaterialApp Bug Report Getx5 : Error when setting URL strategy in GetMaterialApp Sep 26, 2024
@ConschiB
Copy link

ConschiB commented Oct 9, 2024

Same issue. Unfortunately there is currently no way to set showHashOnUrl manually.
if (!showHashOnUrl && GetPlatform.isWeb) setUrlStrategy();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants