PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
55 stars 37 forks source link

Unawaiting captures and screen #39

Closed kyeshmz closed 1 year ago

kyeshmz commented 1 year ago

As most of the library is about exposing the method channels, it seems like we can use unawaited for most of the code, as we don't really use the callback from the future. Should there be an update to the examples?

marandaneto commented 1 year ago

@kyeshmz what do you mean by:

we don't really use the callback from the future

For calls such as Posthog.capture you don't really need to await, but for Posthog.isFeatureEnabled you do otherwise the return is the Future and not the boolean.

kyeshmz commented 1 year ago

I mean that all the exposed methods are Future, which implies that I need to await this. Is there a way to make this simply void?

marandaneto commented 1 year ago

They are void, but Future<void> instead since it's an async method, this is how the language works, so you have the option to either await or not, if we make the option to only void, then the user does not have the option to await if they want to. I'll close it as not being a bug.

https://dart.dev/tools/linter-rules/unawaited_futures You can just do unawaited(doSomething());