flutter_radar_io 0.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

IF YOU ARE AN IOS DEVELOPER, THIS PLUGIN NEEDS YOUR SUPPORT! #

The iOS implementation of this public is incomplete (e.g. it is missing the possibility of setting a callback from dart)

Your contribution would be very appreciated!

⬆️ Flutter Radar.io #

This unofficial plugin allows to use the Radar.io SDK in your Flutter mobile app on iOS and Android. It is still in its early stage but it already allows to use most of the features of the Radar.io SDK.

Development progress #

  • User identification ✔️

  • Foreground tracking ✔️
    Callbacks are in Android only

  • Background tracking ✔️

  • Configuration ✔️
    Currently you can only choose one of the 3
    predefined configurations

  • Event verification ✖️

  • Location search ✖️

  • Geocoding ✖️

  • Distance ✖️

  • Permission request ✖️
    Not a priority as
    there are already many great plugins that perform this

Setup #

Android #

Add the following permissions to your AndroidManifest.xml in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />    
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />    
        <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />    
        <uses-permission android:name="android.permission.ACCESS_ACCESS_NETWORK_STATE" />    
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

iOS #

This plugin requires at least iOS 10.0.

Edit your first line of your PodFile like this:

platform :ios, '10.0'

Then add the following keys to your Info.plist file. Make sure to replace the placeholder descriptions with some meaningful explanation related to why you are requesting these permissions.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>       <string>Your iOS 11 and higher background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>    
            
           <key>NSLocationAlwaysUsageDescription</key>    
           <string>Your iOS 10 and lower background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>    
            
           <key>NSLocationWhenInUseUsageDescription</key>    
           <string>Your foreground location usage description goes here. e.g., "This app uses your location in the foreground to recommend places nearby."</string>    
           <key>UIBackgroundModes</key>    
           <array>    
             <string>fetch</string>    
             <string>location</string>    
           </array>  

Requesting permissions #

Additionally, you will have to manage the location permission request. In the example app, you will see that we have used permission_handler but feel free to use any other plugin you like. If you choose to go with permission permission_handler make sure to follow their installation steps as well.

Usage #

You can check the example for a rather complete implementation and you can always check the Official docs.

0.1.0 #

  • Implemented bidirectional communication for trackOnce on Android

0.0.2 #

  • Fixed iOS build

0.0.1+1 #

  • Fixed Readme.md

0.0.1 #

  • Initial Release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_radar_io/flutter_radar_io.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String userId;
  bool isTracking;
  String status;

  @override
  void initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    try {
    } on PlatformException {

    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              Text("Tracking status: ${isTracking}"),
              Text("TrackOnce status: ${status}"),
              MaterialButton(
                child: Text('Request permissions'),
                onPressed: () async {
                  try {
                    await Permission.locationAlways.request();
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Initialize'),
                onPressed: () async {
                  try {
                    await FlutterRadarIo.initialize(publishableKey: 'YOUR_KEY');
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Set Log Level'),
                onPressed: () async {
                  try {
                    await FlutterRadarIo.setLogLevel(logLevel: FlutterRadarIo.LOG_LEVEL_WARNING);
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Start Tracking'),
                onPressed: () async {
                  try {
                    await FlutterRadarIo.startTracking(preset: FlutterRadarIo.TRACKING_PRESET_CONTINUOUS);
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Stop Tracking'),
                onPressed: () async {
                  try {
                    await FlutterRadarIo.stopTracking();
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Check if tracking'),
                onPressed: () async {
                  try {
                    final bool tracking = await FlutterRadarIo.isTracking();
                    setState(() {
                      isTracking = tracking;
                    });
                  } on PlatformException {
                    print('There has been an error');
                  }
                },
              ),
              MaterialButton(
                child: Text('Track Once'),
                onPressed: () async {
                  try {
                    await FlutterRadarIo.trackOnce(
                            callBack: ({location, radarEvents, radarStatus, radarUser}) {
                              print('callback executing');
                              setState(() {
                                status = radarStatus;
                              });
                              print([radarStatus, location, radarEvents, radarUser]);
                            },);
                  } on Exception {
                    print('There has been an error');
                  }
                },
              )
            ],
          )
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_radar_io: ^0.1.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_radar_io/flutter_radar_io.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:flutter_radar_io/flutter_radar_io.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:flutter_radar_io/flutter_radar_io.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:flutter_radar_io/flutter_radar_io.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:flutter_radar_io/flutter_radar_io.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • flutter_radar_io that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

35 out of 35 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test