InvisibleWrench / FlutterMidiCommand

A Flutter plugin to send and receive MIDI
BSD 3-Clause "New" or "Revised" License
95 stars 50 forks source link

Bluetooth platform support should be optional #46

Open maks opened 2 years ago

maks commented 2 years ago

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?

mortenboye commented 2 years ago

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.

maks commented 2 years ago

Thanks @mortenboye I'll try to get a PR done for this shortly.

richardjharris commented 2 years ago

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!

maks commented 2 years ago

@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 commented 2 years ago

Okay thanks, I tried the example app and it errors immediately like you describe, I will try making a new app from scratch instead :)

On Thu, 10 Mar 2022, 22:03 Maksim Lin, @.***> wrote:

@richardjharris https://github.com/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.

— Reply to this email directly, view it on GitHub https://github.com/InvisibleWrench/FlutterMidiCommand/issues/46#issuecomment-1064546531, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABIXXXOJYTYQG7WV7P7RT3U7JWUJANCNFSM5OCW235A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

maks commented 2 years ago

@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:

image