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

[iOS] Entering page again to initialize, the last statusListener is unable to update widgets. #514

Open
wtto00 opened this issue Apr 25, 2024 · 2 comments

Comments

@wtto00
Copy link

wtto00 commented Apr 25, 2024

When you first enter the page, initialize and bind the onStatus parameter statusListener. In the callback, change the state widget.

When you navigator back and enter the page again, re-execute initialize, which will execute the return successfully without overwriting the new statusListener callback. This will cause the widget changed in the callback to be the widget of the first initialized page, rather than the state widget of the current page, resulting in the inability to change the state widget of the current page.

You can only manually reassign statusListener = _statusListener, rebind the state change callback to update the state widget of the current page.

@hamiranisahil
Copy link

hamiranisahil commented Jun 12, 2024

I found in the README that the initialize method only needs to be called once per application session. So, this behavior is expected according to the package.

Suggestion: There are two methods, stop() and cancel(). stop should remain as is, but cancel should reset all configurations, requiring the user to call initialize() again after cancellation. If users want to initialize only once per application session, they can manage it accordingly.

Workaround Solution:

The statusListener and errorListener can be set manually if needed. This can help if anyone is stuck with a similar issue:

_speech.initialize(
    onStatus: statusListener,
    onError: errorListener,
    debugLogging: kDebugMode,
);
_speech.statusListener ??= statusListener;
_speech.errorListener ??= errorListener;

@PetrKubes97
Copy link

This is happening on Android as well and the workaround fixes the issue. Thanks!

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