1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter blue plus connection state listener

Discussão em 'Mobile' iniciado por Stack, Outubro 1, 2024 às 10:32.

  1. Stack

    Stack Membro Participativo

    I have an app that uses flutter_blue_plus and I want to add a listener to the connection state of the device. As soon as the device loose connection I want to show a popup anywhere inside my app to inform the user that they lost connection. I have multiple screens so where should I setup the listener so it can popup anywhere in my app? If I set up my listener in 'main.screen' will it be able to show popup all around the app?

    I connect to my device on my 'main.screen'

    This is the documentation from flutter_blue_plus:

    // tip: using ??= makes it easy to only make new listener when currently null
    final subscription ??= FlutterBluePlus.device.connectionState.listen((value) {
    // ...
    });

    // also, make sure you cancel the subscription when done!
    subscription.cancel()


    How can I use this globally in my app?

    Continue reading...

Compartilhe esta Página