Bluetooth platform support should be optional
Opened this issue · 6 comments
Currently there is no way for a platform plugin to indicate that it doesn't support bluetooth, so on Linux for example this causes the following exception:
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: UnimplementedError: get onBluetoothStateChanged has not been implemented.
#0 MidiCommandPlatform.onBluetoothStateChanged
package:flutter_midi_command_platform_interface/flutter_midi_command_platform_interface.dart:47
#1 MidiCommand._listenToBluetoothState
package:flutter_midi_command/flutter_midi_command.dart:49
#2 new MidiCommand._
package:flutter_midi_command/flutter_midi_command.dart:28
#3 new MidiCommand
package:flutter_midi_command/flutter_midi_command.dart:22
Perhaps MidiCommandPlatform
could have a boolean getter added that platforms could use to indicate whether or not they support bluetooth and then the code that setups the _onBluetoothStateChangedStreamSubscription
stream could check that before attempting to listen to that stream?
This is a valid point and a good suggestion. Feel free to submit another PR, otherwise I will look into in in a few weeks time.
Thanks @mortenboye I'll try to get a PR done for this shortly.
Hi, I just installed this library and got the same error. Is there a workaround I can apply, or do I need to wait for a new release before the library will work on Linux?
Thanks for your hard work!
@richardjharris the error doesn't stop it working on Linux, in fact its working very well for me at the moment in an application that uses MIDI heavily including send/receiving large sysex messages.
This error is more annoyance than show-stopper. It shows in your debug console everytime you restart, but that's about it.
Unfortunately I haven't had a chance yet to get a PR done for it, but I'll try to get that done soon.
@richardjharris I just tried the example app too. Yes you will get that error immediately and if you running using debug in VSCode or AndroidStudio with breakpoints "Uncaught Exceptions" you will get the debugger paused on that exception but the app still runs fine and as you can see in my screenshot it still detects available Midi devices: