Octant

Octant is a location tacking service, developed and maintained by Nextbillion.Pte.Ltd

Before we invoking any other functions from Octant, we have to call Octant.init(userId, teamCode, baseUrl) to initialize the service.

in order to keep Octant's Android Service alive, we are going to start a foreground service, so we have to specify drawable name, title and content for an ongoing notification that we are going to post.

for drawableName convention, let's say we have an icon located at drawables folder, named R.drawable.ic_launcher, please pass drawableName as ic_launcher to Octant.startService().

before we calling Octant.startTracing(), we need to make sure Octant Service has started. otherwise there will be an error thrown.

Example

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    Octant.init('1', '1', 'replace your base url here');
    Octant.enableDebug(true);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                height: 50,
              ),
              GradientButton('start service', () {
                Octant.startService('ic_launcher', 'Octant Example',
                    'location tracking in progress...');
              }),
              Container(
                height: 50,
              ),
              const GradientButton('start tracing', Octant.startTracing),
              Container(
                height: 50,
              ),
              const GradientButton('stop service', Octant.stopService),
              Container(
                height: 50,
              ),
              GradientButton('Configure intervals', () {
                Octant.configureIntervals(12, 1);
              }),
              Container(
                height: 50,
              ),
              GradientButton('QueryRanking', () {
                int startTime = DateTime.now()
                    .subtract(const Duration(days: 7))
                    .millisecond;
                int endTime = DateTime.now().microsecond;
                int limit = 10;
                String remarkCode = "0";
                List<String> userCodeList = ['0', '1', '2'];
                Octant.queryRanking(
                    startTime, endTime, limit, userCodeList, remarkCode);
              }),
              Container(
                height: 50,
              ),
              GradientButton('QueryUserCoord', () {
                int startTime = DateTime.now()
                    .subtract(const Duration(days: 7))
                    .millisecond;
                int endTime = DateTime.now().microsecond;
                int limit = 10;
                String remarkCode = "0";
                Octant.queryUserCoordinate(
                    startTime, endTime, limit, remarkCode);
              }),
            ],
          ),
        ),
      ),
    );
  }
}