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

replaceBinds can be called on fly? #909

Closed
cl0v opened this issue Oct 19, 2023 · 2 comments
Closed

replaceBinds can be called on fly? #909

cl0v opened this issue Oct 19, 2023 · 2 comments
Labels
new New issue request attention question Questions about using some feature or general working of the package

Comments

@cl0v
Copy link

cl0v commented Oct 19, 2023

Is there any way to call replaceBinds after the module has been initialized?

I'm coding a itegration test on a Modular App, and the moment the app initializes the flow keeps going, using the default modules (AppModule, AuthModule, finally CashierModule).
But they come in order, the last step is the CashierModule, which initialized his own module after the QR scanner has been completed.
If i try to initModule(CashierModule(), replaceBinds: [mockedBind]), it seems that the app will create a new instance of this module (not tested) when the moment arrives. But i think this is expected.

But when i try to initModule after the default cashier module has been initialized by the app integration flow, it seems to have no effect replacing the desired bind

@cl0v cl0v added new New issue request attention question Questions about using some feature or general working of the package labels Oct 19, 2023
@cl0v
Copy link
Author

cl0v commented Oct 24, 2023

I'm trying to use Modular.replaceInstance(dioMock); as shown in https://modular.flutterando.com.br/docs/flutter_modular/test/#injection-test but it seems that Modular removed this static method... Error:
The method 'replaceInstance' isn't defined for the type 'IModularBase'. Try correcting the name to the name of an existing method, or defining a method named 'replaceInstance'

@cl0v
Copy link
Author

cl0v commented Oct 24, 2023

Sorry, I was using flutter_modular version 5. Upgrading to version ˆ6 will solve the issue. Thx =D

@cl0v cl0v closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New issue request attention question Questions about using some feature or general working of the package
Projects
None yet
Development

No branches or pull requests

1 participant