flutter-geolocator

repository·main·Indexed 23 days ago

https://github.com/baseflow/flutter-geolocator

A federated Flutter plugin providing location services across Android, iOS, macOS, Web, and Windows. It consists of a main app-facing package and platform-specific implementations including geolocator_android, geolocator_apple, geolocator_web, and geolocator_windows. The plugin supports advanced Android features such as GNSS satellite data via AndroidPosition and foreground service notifications via ForegroundNotificationConfig.

Tokens
4.6K
Snippets
5
Records
36
Agent score
76%

What's inside flutter-geolocator

  1. How the Geolocator platform interface works

    main
    The geolocator_platform_interface package provides a common interface used by the main geolocator plugin and its various platform-specific implementations. This architecture follows the Flutter Federated Plugins pattern, ensuring that all platform implementations (e.g., Android, iOS, Web) adhere to the same API contract. This allows the consumer-facing geolocator package to remain platform-agnostic while delegating actual location logic to the registered GeolocatorPlatform implementation.
  2. Understand the geolocator federated plugin architecture

    main
    The geolocator plugin uses a federated architecture, meaning the functionality is split across several specialized packages. As an end-user, you should primarily interact with the geolocator package, which serves as the single app-facing entry point. The other packages (geolocator_android, geolocator_apple, geolocator_web, geolocator_windows, and geolocator_platform_interface) provide the underlying platform-specific implementations and the interface definitions that allow the main package to work across different operating systems.
  3. Use the geolocator app-facing package

    main
    To use geolocator in your Flutter project, depend on the geolocator package. This is the main package that provides the API you will call in your application code. For specific API usage, installation steps, and configuration, refer to the geolocator package's own documentation.
  4. Install geolocator_apple for iOS and macOS

    main
    The geolocator_apple package is the official implementation for iOS and macOS. Since version 7.5.0 of the main geolocator plugin, this implementation is automatically included as a dependency when you add geolocator to your pubspec.yaml. You do not need to add geolocator_apple explicitly unless you have a specific requirement to override the default implementation.
  5. Run the geolocator_web example app

    main

    To run the demonstration application for geolocator_web in a Chrome browser, follow these steps from the root of the repository:

    1. Navigate to the example directory: cd geolocator_web/example
    2. Install dependencies: flutter pub get
    3. Launch the app in Chrome: flutter run -d chrome
    cd geolocator_web/example
    flutter pub get
    flutter run -d chrome
  6. Customize the iOS launch screen assets

    main

    To change the image displayed during the app's launch on iOS, you can either replace the image files directly in the geolocator_apple/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory or use Xcode for a more visual approach.

    Using Xcode:

    1. Open the iOS workspace by running open ios/Runner.xcworkspace from your terminal.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog to replace the existing launch screen assets.
    open ios/Runner.xcworkspace