-
Notifications
You must be signed in to change notification settings - Fork 484
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
refactor: migrate to federated architecture #971
Conversation
yes I really dont like these in particular. |
must support optional secondaryServiceUuid as well. same with the others. |
No problem, I can rename them accordingly, I was attempting to name them generically not Android specific 😄 |
Of course, I can add
|
theres an outstanding github issue to fix secondary services: #948 |
Thank you very much for your feedback, I have applied your suggestions from the code review. If you are happy to proceed then I will create auxiliary classes in the platform interface that I will gladly maintain 😄 |
looks good! just saw this comment |
this should probably take arbitrary keys and values. a Map<String,dynamic> I just added a new option today (12c17a6) needs to be future proof. |
Also I wonder if we should have more future proofing
or maybe just
|
but im still not that knowledgable about designing these interfaces. I think you know more than me about this. |
In this scenario we should add that parameter to the method and give it a reasonable default for compatibility. Future<void> setOptions({
bool darwinShowPowerAlert = true,
bool iosRestoreState = false, // or true
}) {
throw UnimplementedError();
}
Personally I would strongly avoid that because platform interfaces conventionally define properties and/or methods for the functionality. When functionality is added to |
let’s say the Windows 12 comes out and adds a few new ble functions. will the platform interface have to change? or let’s say we want to add more arguments to setOptions. will the platform implantations all break? |
In this scenario we should add those new method(s) to the platform interface as a non-breaking change e.g. Future<void> newMethod() {
throw UnimplementedError();
}
If we make a breaking change to the platform interface then this should be published as a breaking change. If we expect options (for example) to change often then we should probably consider something like this: class Options {
final bool darwinShowPowerAlert;
final bool additionalParameter;
Options({
this.darwinShowPowerAlert = true,
this.additionalParameter = false, // or true
});
}
abstract base class FlutterBluePlusPlatform {
Future<void> setOptions(
Options options,
) {
throw UnimplementedError();
}
} |
let's make the platform interface as future proof as possible options will evolve over time i don't want to have to maintain windows, web, linux, as they evolve so the platform interface should allow them enough flexibility to add new functions without my involvement |
Just to confirm that the platform interface may have methods added to it in the future to cover potential functionality. One of the reasons for a platform interface is that it is the interface used by all platforms not just Android/iOS/macOS. |
I would be more than happy to maintain the platform interface in collaboration with you to reduce your burden. Just double checking that you're happy to continue with us creating a platform interface for |
what is the status of being able to do things like this?
did we come to a solution? |
Researching other examples of platform interfaces that typically isn't how they are created.
This implies that each platform has its own interface and so isn't a shared platform interface.
|
That isn't to say that you couldn't do that in the existing |
what would the user facing API be? If not Maybe |
The methods in the platform interface could be as per the changes in this pull request, whilst the methods in The methods in the platform interface should then be implemented by each platform specific implementation where appropriate and possible, throwing an unsupported error if that particular method is not supported on the platform. |
Maybe im not clear. Does the platform interface need to be a superset of all platforms? There's no way for each implementation to expose custom functions and options themselves? If so, that's pretty annoying because every addition will require the platform interface to change. android has like 50 difference custom functions and flags. iOS has at least 20. I imagine web, linux, windows, also have lots of custom features. FBP eventually needs to support all of these features. each platform needs more autonomy. |
Have you seen this package? https://pub.dev/packages/flutter_blue_plus_windows He added Windows support to FBP without any involvement from me. He used a wrapper architecture: Perhaps you can add linux & web in a similar fashion? |
Yes, the platform interface should be a superset of all platforms, otherwise it is not a "true" platform interface. I would encourage you to take a look at the platform interfaces that I previously linked to and those here for inspiration. When adding a method to one or more platforms, it should be added to the platform interface, then implemented in the platforms that support that particular functionality. |
Unfortunately, this is just not something I'm comfortable maintaining long term. I know I wont have enough enthusiasm make each platform a first class citizen.
I appreciate that offer! But I think then FBP for android/ios/mac would not be fully autonomous? That would make development of the main platforms harder. I think you should consider that approach taken by https://pub.dev/packages/flutter_blue_plus_windows. It's much more autonomous, and the "wrapper" is not that difficult to write/maintain. |
Unfortunately as Stuart highlighted in this issue, that approach has a number of significant disadvantages including being very fragile and prone to breakage. This makes ongoing maintenance of the platform implementation a lot more complicated compared to simply implementing a platform interface. It is a shame that |
I share your disappointment. But I just don't have the bandwidth to do it justice. I welcome you to create Yes, there are tradeoffs for all the approaches, to be sure. Thanks for your time in evaluate the federated approach. I'm sorry that I was ultimately not up for it. |
#969 (comment)