Lyokone / flutterlocation

A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.
MIT License
1.11k stars 820 forks source link

In 5.0.0 the `Location` class is replaced by functions, functions cannot be easily mocked #837

Closed akvus closed 1 year ago

akvus commented 1 year ago

Description The Location class in 5.0.0 is replaced by functions. Functions cannot be easily mocked. Also, should functions be passed around as dependencies? Direct calls to these functions i.e. in notifiers or blocs make it hard to run unit tests in isolation for these classes.

This depends on an app's architecture, but assuming a project is using some kind of DI/service location with injection into constructors then an instance of a class can be mocked for testing purposes with mockito or mocktail.

In order to migrate to the 5.0.0 version, projects will have to introduce their own Location class that will be wrapping the functions this package is providing. Is that intended?

bartekpacia commented 1 year ago

This is a valid concern.

I might revert those changes to preserve the current API so there'll be no migration pain.

bartekpacia commented 1 year ago

I don't plan on releasing the code on develop branch.

See also #870.