Geolite Flutter SDK

A Flutter package that provides access to the Geolite SDK native functionality for both Android and iOS platforms.

Features

  • Initialize the Geolite SDK with an API key, cipher key, and user ID
  • Request location permissions
  • Stop location tracking

Getting Started

To use this plugin, add geolite_flutter_sdk as a dependency in your pubspec.yaml file:

dependencies:
  geolite_flutter_sdk: ^0.0.1

Then run:

flutter pub get

Android Setup

The Android implementation requires the following permissions in your Android manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

For Android 10+ (API level 29+), you'll also need to add:

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Make sure to request these permissions at runtime for Android 6.0 (API level 23) or higher.

iOS Setup

The iOS implementation requires the following entries in your Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when in use to track your position.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when in use and in background to track your position.</string>
<key>UIBackgroundModes</key>
<array>
    <string>location</string>
</array>

Usage

import 'package:geolite_flutter_sdk/geolite_flutter_sdk.dart';

// Request location permissions first
bool permissionGranted = await GeoliteFlutterSdk.requestLocationPermission();

if (permissionGranted) {
  // Initialize the SDK
  Map<String, dynamic> result = await GeoliteFlutterSdk.initialiseSDK(
    'your_api_key_here',
    'your_cipher_key_here',
    'your_user_id_here',
  );

  if (result['success'] == true) {
    print("SDK initialized successfully");
  } else {
    print("Failed to initialize SDK: ${result['errormessage']}");
  }

  // When you want to stop tracking:
  Map<String, dynamic> stopResult = await GeoliteFlutterSdk.stopTracking();
  if (stopResult['success'] == true) {
    print("Tracking stopped successfully");
  }
}

Example App

Check the example directory for a sample app demonstrating the usage of this plugin.

Additional Information

Dependencies

  • Flutter
  • Android Geolite SDK (included as AAR)
  • iOS Geolite SDK (included as Framework)

License

This project is licensed under the MIT License - see the LICENSE file for details.