Skip to content
  • B'Elanna Michalke @BElannaMichalke ·

    How to use FLOSS Geolocator for Flutter applications:

    Import normal geolocator as known. You may also use other packages using geolocator as dependency.

    dependencies:
      flutter:
        sdk: flutter
      geolocator: ^7.6.2

    To use FLOSS geolocator (e.g. only for the FLOSS builds), you can simply add a dependency override. This ensures other dependencies using geolocator are forced to use the FLOSS version too:

    dependency_overrides:
      geolocator_android:
        hosted:
          name: geolocator_android
          url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss

    Please note the override no longer overrides geolocator but geolocator_android.

    Edited by B'Elanna Michalke
  • B'Elanna Michalke @BElannaMichalke ·

    Was moved to https://gitlab.com/hanntech-gmbh/free2pass/flutter-geolocator-floss. It actually properly redirects.

  • B'Elanna Michalke @BElannaMichalke ·

    Thanks to a nice discussion with @KrilleFear, the FLOSSed Flutter geolocator now got rid of the ugly git override and provides its own package automatically created server in CI/CD jobs. This permits to drop in the FLOSSed version once without any later modifications like e.g. updated versions / refs or Git imports in production builds. This was realized by a little utility called repo_pub_server.

  • For the latest version of the geolocator override, use this for your pubspec:

    dependency_overrides:
      geolocator_android:
        git:
          url: https://github.com/Zverik/flutter-geolocator.git
          ref: floss
          path: geolocator_android
  • [Flutter] Working with dependencies that rely on GMS

    If the following matches to you:

    • You use Flutter
    • You develop two variants (or more) of your app, of which
      • one relies on GMS related dependencies and
      • the other one should be completely libre (without any GMS) and
    • one dependency that depends on GMS does not work in the libre version, even when you wouldn't use it

    you can try the following workaround. Note that I am completely disabling the functionality here in the FLOSS version.

    1. Create a local Flutter package and name it exactly like your dependency (for reference: https://docs.flutter.dev/packages-and-plugins/developing-packages): flutter create --template=package dependency_name_here
    2. Copy the classes, functions, etc. and make them empty / write throw UnimplementedError
    3. In your pubspec.yaml, use dependency_override to override the package with your local one

    Example

    This was all a bit abstract, let's see a real example.

    Context I have a project (https://github.com/Myzel394/locus) that should be built for two variants: GMS and FLOSS. For the GMS variant, I wanted to add Bluetooth file sharing support. To achieve this, I used the nearby_connections package. Unfortunately this resulted in some things not working in the FLOSS variant anymore. The reason for this is a bit complicated, see this issue for more info.

    Since I was okay with the GMS variant only having the Bluetooth file sharing functionality, it was very easy to get the app up and running again using this workaround. Here's what I did:

    • I created a folder at the root called dependency_overrides
    • Inside the folder I created a local Flutter package: flutter create --template=package nearby_connections
    • I copied all classes, functions, enums, etc. from nearby_connections and made them empty. See this folder for more - especially this file contains all the "fake" classes, functions. etc
    • Inside my pubspec.yaml, I'm overriding the dependency when building for FLOSS
    • And now everything is running and working again! 🥳

    To see the full example, take a look at the app (and don't forget to leave a star :D)

    Edited by Myzel394 Xyllian
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment