initialize static method
void
initialize()
Startup; needed to setup all callbacks and prevent race-issues.
Implementation
static void initialize() {
var completer = new Completer<void>();
_broadcastLocationStream = _userLocationUpdated.stream.asBroadcastStream();
_channel.setMethodCallHandler((call) async {
if (call.method == "entry") {
Geolocation location = Geolocation(
latitude: call.arguments["latitude"] as double,
longitude: call.arguments["longitude"] as double,
radius: call.arguments["radius"] as double,
id: call.arguments["id"] as String);
_entryCallback(location);
} else if (call.method == "exit") {
Geolocation location = Geolocation(
latitude: call.arguments["latitude"] as double,
longitude: call.arguments["longitude"] as double,
radius: call.arguments["radius"] as double,
id: call.arguments["id"] as String);
_exitCallback(location);
} else if (call.method == "userLocationUpdated") {
Coordinate coordinate =
Coordinate(call.arguments["lat"], call.arguments["lng"]);
_userLocationUpdated.sink.add(coordinate);
} else if (call.method == "backgroundLocationUpdated") {
Coordinate coordinate =
Coordinate(call.arguments["lat"], call.arguments["lng"]);
backgroundLocationUpdated.sink.add(coordinate);
}
completer.complete();
});
}