ajlocation 1.0.0
ajlocation: ^1.0.0 copied to clipboard
Native location plugin for iOS and Android.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:ajlocation/ajlocation.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
Future requestAlways() async {
var response = await AJLocation.requestAuthorization(type: AuthorizationType.always);
print(response.toString());
}
Future requestOnly() async {
var response = await AJLocation.requestAuthorization(type: AuthorizationType.inUse);
print(response.toString());
}
Future currentStatus() async {
var response = await AJLocation.currentAuthorizationStatus;
print(response.toString());
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text("Request Authorization Always/Background"),
onPressed: () {
requestAlways();
},
),
FlatButton(
child: Text("Request Authorization Only when in use"),
onPressed: () {
requestOnly();
},
),
FlatButton(
child: Text("Authorization Status"),
onPressed: () {
currentStatus();
},
),
FlatButton(
child: Text("Set configuration"),
onPressed: () {
AJLocation.setConfiguartion(accuracy: AccuracyType.nearestTenMeters, distanceFilter: 5.0);
},
),
FlatButton(
child: Text("Start updating location"),
onPressed: () {
AJLocation.startUpdatingLocation();
},
),
FlatButton(
child: Text("Stop updating location"),
onPressed: () {
AJLocation.stopUpdatingLocation();
},
),
FlatButton(
child: Text("Listen to changes"),
onPressed: () {
AJLocation.onLocationChange.listen((data) {
print(data);
});
},
),
],
)
),
),
);
}
}