Skip to content

How to properly manage AntSDK WebSocket connections in Flutter when navigating away from a page #7121

@kimPongsakorn

Description

@kimPongsakorn

How to properly manage AntSDK WebSocket connections in Flutter when navigating away from a page

Issue
I'm developing a Flutter app using AntSDK and encountering an issue with WebSocket connection management:

  1. When I initiate an AntSDK connection on a page and navigate away before the WebSocket connection completes
  2. The AntSDK continues attempting to connect in the background
  3. When the connection eventually completes, the Ant audio gets stuck in the app
  4. If I return to the original page, there's an audio overlap issue, as if both old and new Ant instances are running simultaneously

What I need:

  • Terminate the WebSocket connection when navigating away from the page

  • Completely clear the Ant instance when not in use

  • Stop all AntSDK-related processes when not on that page
    What I've tried
    dart

    @OverRide
    void dispose() {
    // I've tried using the standard dispose method but it doesn't solve the issue
    super.dispose();
    }

Questions

  1. What is the correct way to disconnect AntSDK and stop all processes when navigating away from a page?
  2. Is there a specific method needed to directly close the WebSocket connection?
  3. Are there any best practices for managing the lifecycle of AntSDK in a Flutter app?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions