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

No devices are found #167

Open
jcm10x1 opened this issue Jan 17, 2024 · 0 comments
Open

No devices are found #167

jcm10x1 opened this issue Jan 17, 2024 · 0 comments

Comments

@jcm10x1
Copy link

jcm10x1 commented Jan 17, 2024

Here is the code I have to locate found devices. "FOUND A DEVICE" is never printed. Other packages and apps do find plenty of devices. I am currently on Android 10 and the quick_blue version is 0.4.1+1.

  @override
  void initState() {
    super.initState();

    startScanning();
    print('INIT STATE');
  }

  void startScanning() async {
    final location = await Permission.location.status;
    if (!location.isGranted) {
      await Permission.location.request();
    }
    final bluetooth = await Permission.bluetooth.status;
    if (!bluetooth.isGranted) {
      await Permission.bluetooth.request();
    }

    if (await QuickBlue.isBluetoothAvailable() == false) {
      print('BLUETOOTH NOT AVAILABLE');
      return;
    }
    QuickBlue.scanResultStream.listen(
      (result) {
        print('FOUND A DEVICE');
        if (!devices.contains(result) && result.name != '') {
          setState(() {
            print(result.name);
            devices.add(result);
          });
        }
      },
      onError: (e) {
        print('ERROR: $e');
      },
      onDone: () => print('DONE'),
    );
    QuickBlue.startScan();
    print('STARTED SCANNING');
  }
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

1 participant