The locations sensor provides the best location estimate for the users’ current location, automatically.
- Edit
pubspec.yaml
dependencies:
awareframework_locations
- Import the package on your source code
import 'package:awareframework_locations/awareframework_locations.dart';
import 'package:awareframework_core/awareframework_core.dart';
- For iOS
Open your project ( *.xcworkspace ) and add NSLocationAlwaysAndWhenInUseUsageDescription
and NSLocationWhenInUseUsageDescription
, NSLocationAlwaysUsageDescription
into Info.plist.
start()
stop()
sync(bool force)
enable()
disable()
isEnable()
setLabel(String label)
geoFences: String?
Geofences that are going to be checked on the location updates. If within the range of these fences, then the location is accepted as a permitted update. If null, all location updates are accepted as permitted. String follows the regex in format(?:latitude),(?:longitude)[ \t;]+
. (default =null
)statusGps: Boolean
true or false to activate or deactivate GPS locations. (default =true
) Android OnlystatusNetwork: Boolean
true or false to activate or deactivate Network locations. (default =true
) Android OnlystatusPassive: Boolean
true or false to activate or deactivate passive locations. (default =true
) Android OnlyfrequencyGps: Int
how frequent to check the GPS location, in seconds. By default, every 180 seconds. Setting to 0 (zero) will keep the GPS location tracking always on. (default = 180)minGpsAccuracy: Int
the minimum acceptable accuracy of GPS location, in meters. By default, 150 meters. Setting to 0 (zero) will keep the GPS location tracking always on. (default = 150)frequencyNetwork: Int
how frequently to check the network location, in seconds. By default, every 300 seconds. Setting to 0 (zero) will keep the network location tracking always on. (default = 300) Android OnlyminNetworkAccuracy: Int
the minimum acceptable accuracy of network location, in meters. By default, 1500 meters. Setting to 0 (zero) will keep the network location tracking always on. (default = 1500) Android OnlyexpirationTime: Long
the amount of elapsed time, in seconds, until the location is considered outdated. By default, 300 seconds. (default = 300)saveAll: Boolean
Whether to save all the location updates or not. (default =false
)enabled: Boolean
Sensor is enabled or not. (default =false
)debug: Boolean
enable/disable logging toLogcat
. (default =false
)label: String
Label for the data. (default = "")deviceId: String
Id of the device that will be associated with the events and the sensor. (default = "")dbEncryptionKey
Encryption key for the database. (default =null
)dbType: Engine
Which db engine to use for saving data. (default =Engine.DatabaseType.NONE
)dbPath: String
Path of the database. (default = "aware_locations")dbHost: String
Host for syncing the database. (default =null
)
The data representations is different between Android and iOS. Following links provide the information.
// init config
var config = LocationsSensorConfig()
..debug = true
..label = "label";
// init sensor
var sensor = new LocationsSensor(config);
void method(){
/// start
sensor.start();
/// set observer
sensor.onLocationChanged.listen((LocationData data){
setState((){
// Your code here
});
});
/// stop
sensor.stop();
/// sync
sensor.sync(true);
// make a sensor care by the following code
var card = new LocationCard(sensor:sensor);
// NEXT: Add the card instance into a target Widget.
}
Copyright (c) 2018 AWARE Mobile Context Instrumentation Middleware/Framework (http://www.awareframework.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LI CENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.