Version 5.0.0 introduced a Compound Config format to replace the legacy "flat" configuration structure. While the legacy flat style remains supported for backward compatibility, new features may only be available in the compound structure.
Migration Steps:
- Update dependency: Ensure you are using
flutter_background_geolocation v5.0.0 or later. - Android Cleanup: Remove custom
maven url entries from android/build.gradle. The local libs repositories for flutter_background_geolocation and background_fetch are no longer required. - Group Options: Move related keys into their respective configuration classes (e.g.,
GeoConfig, HttpConfig, AppConfig). - Replace Keys: Pass the new compound config objects into
BackgroundGeolocation.ready(Config(...)) instead of passing all options at the top level.
// After (Compound Config)
BackgroundGeolocation.ready(Config(
geolocation: GeoConfig(
desiredAccuracy: DesiredAccuracy.high,
distanceFilter: 50,
),
app: AppConfig(
stopOnTerminate: false,
startOnBoot: true,
),
http: HttpConfig(
url: "https://my.server.com/locations",
headers: { "Authorization": "Bearer TOKEN" },
),
logger: LoggerConfig(
logLevel: LogLevel.verbose,
debug: true,
),
));