woodemi / quick.flutter

54 stars 64 forks source link

Help installing Quick Blue on Linux #92

Closed JoshPlayer1 closed 1 year ago

JoshPlayer1 commented 1 year ago

Hi, I'm new to flutter and I'm trying to use quick_blue to connect to a BLE device with Linux. I see that in the mono repo Linux is supported, but the packages on pub.dev do not.

I've also tried putting this into my pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

  quick_blue:
    git:
      url: https://github.com/woodemi/quick.flutter.git
      path: packages/quick_blue

which results in this error I struggle to understand when trying to just run :

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method startScan on channel quick_blue/method)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)
<asynchronous suspension>
#1      MethodChannelQuickBlue.startScan (package:quick_blue/src/method_channel_quick_blue.dart:43:5)
<asynchronous suspension>

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following MissingPluginException was thrown while activating platform stream on channel
quick_blue/event.scanResult:
MissingPluginException(No implementation found for method listen on channel
quick_blue/event.scanResult)

When the exception was thrown, this was the stack:
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)
<asynchronous suspension>
#1      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:652:9)
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════════════════════════

Here is my implementation that works from pub, but results in the above error from git method.

class BluetoothTesting extends StatelessWidget {
  const BluetoothTesting({super.key});
  @override
  Widget build(BuildContext context) {
    QuickBlue.scanResultStream.listen((result) {
      String name = result.name;
      print('onScanResult $name');
    });
    print("here");
    QuickBlue.startScan();
    return Scaffold(
      appBar: AppBar(
        title: const Text("Bluetooth Tests"),
      ),
    );
  }
}

Thanks, Josh

JoshPlayer1 commented 1 year ago

Resolved, it works when including QuickBlueLinux.registerWith();