A most easily usable Geo Location API wrapper in Dart!

GitHub Gmail Line Twitter

pub package codecov Analyzer Test

1. About

OneTrustGeoLocation is an open-sourced Dart library.
With OneTrustGeoLocation, you can easily and safely use Geo Location API made by OneTrust on your application.

This is an unofficial library.

1.1. Introduction

1.1.1. What You Can Get

It is possible to get an approximate value for the current position. Note that the values such as zipcode and longitude/latitude are approximations and are not accurate.

For more details on the response data, refer to the GeoLocationResponse class or the original JSON data.

1.1.2. Install Library

With Dart:

 dart pub add one_trust_geo_location

With Flutter:

 flutter pub add one_trust_geo_location

1.1.3. Import It

import 'package:one_trust_geo_location/one_trust_geo_location.dart';

1.1.4. Use OneTrustGeoLocation

import 'package:one_trust_geo_location/one_trust_geo_location.dart' as location;

void main() async {
  // It's very easy to call api with get function.
  // It has no class so it's better to set alias 'location' like below.
  final response = await location.get();

  if (response.status.isNotOk) {
    // Do something when it's client or server error.
    if (response.status.isClientError) {
      return;
    } else if (response.status.isServerError) {
      return;
    } else {
      return;
    }
  }

  print(response.country);
  print(response.latitude);
  print(response.longitude);
}

1.2. License

Copyright (c) 2021, Kato Shinya. All rights reserved.
Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.

1.3. More Information

OneTrustGeoLocation was designed and implemented by Kato Shinya.