'Flutter Blue Scan Results Empty

When running the following sample code from Flutter Blue's pub page to scan for nearby devices, the list returns as empty on my Android device. When going to settings I see the name of my BLE device.

The code is:

FlutterBlue flutterBlue = FlutterBlue.instance;

flutterBlue.startScan(timeout: Duration(seconds: 4));

var subscription = flutterBlue.scanResults.listen((results) {
    // this code is run almost immediately rather than after a 4 second timeout.
    for (ScanResult r in results) {
        print('${r.device.name} found! rssi: ${r.rssi}');
    }
});

//Ive tried with and without the following line
flutterBlue.stopScan();

Bluetooth and location permissions are enabled on the app.

What are some things that could be causing this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source