octant 0.1.4 octant: ^0.1.4 copied to clipboard
Octant is a lightweight SDK that helps to collect and report device's location and provides API to query users' travelled distance or history locations.
import 'package:flutter/material.dart';
import 'package:octant/octant.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
Octant.init('1', teamCode: '1', baseUrl: 'https://nextbillion.zodme.com');
Octant.enableDebug(true);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
GradientButton('start service', () {
Octant.startService(
notificationDrawable: 'ic_launcher',
notificationTitle: 'Octant Example',
notificationContent: 'location tracking in progress...');
}),
const GradientButton('start tracing', Octant.startTracing),
const GradientButton('stop service', Octant.stopService),
GradientButton('Configure intervals', () {
Octant.configureIntervals(
gatheringInterval: 12, uploadingInterval: 1);
}),
GradientButton('QueryRanking', () {
int startTime = DateTime.now()
.subtract(const Duration(days: 7))
.millisecond;
int endTime = DateTime.now().microsecond;
int limit = 10;
List<String> userCodeList = ['0', '1', '2'];
Octant.queryRanking(
startTime: startTime,
endTime: endTime,
limit: limit,
userCodeList: userCodeList);
}),
GradientButton('QueryUserCoord', () {
int startTime = DateTime.now()
.subtract(const Duration(days: 7))
.millisecond;
int endTime = DateTime.now().microsecond;
int limit = 10;
Octant.queryUserCoordinate(
startTime: startTime, endTime: endTime, limit: limit);
}),
],
),
),
),
);
}
}
class GradientButton extends StatelessWidget {
const GradientButton(this.text, this.onPressed, {Key? key}) : super(key: key);
final String text;
final VoidCallback? onPressed;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
height: 50,
margin: const EdgeInsets.fromLTRB(16, 50, 16, 16),
child: RaisedButton(
onPressed: onPressed,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(80)),
padding: const EdgeInsets.all(0),
child: Ink(
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Color(0xff007bff), Color(0xff64B6ff)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(30.0)),
child: Container(
constraints: const BoxConstraints(minHeight: 50, maxWidth: 250),
alignment: Alignment.center,
child: Text(
text,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white),
),
),
),
),
);
}
}