FlutterMidiCommand icon indicating copy to clipboard operation
FlutterMidiCommand copied to clipboard

Bluetooth platform support should be optional

Open maks opened this issue 3 years ago • 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?

maks avatar Feb 11 '22 01:02 maks

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.

mortenboye avatar Feb 13 '22 06:02 mortenboye

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

maks avatar Feb 13 '22 23:02 maks

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 avatar Mar 10 '22 16:03 richardjharris

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

maks avatar Mar 10 '22 22:03 maks

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

richardjharris avatar Mar 10 '22 23:03 richardjharris

@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

maks avatar Mar 10 '22 23:03 maks