what3words 3.2.0 copy "what3words: ^3.2.0" to clipboard
what3words: ^3.2.0 copied to clipboard

A Dart library to use the what3words v3 API. This library can either be used in native Dart or Flutter applications

example/example.dart

import 'package:what3words/what3words.dart';

void main() async {
  // For all requests a what3words API key is needed
  var api = What3WordsV3('what3words-api-key');

  // Create and execute a request to obtain a grid section within the provided bounding box
  var coordinates = await api.convertToCoordinates('index.home.raft').execute();

  if (coordinates.isSuccessful()) {
    print('Coordinates ${coordinates.data()?.toJson()}');
  } else {
    var error = coordinates.error();

    if (error == What3WordsError.BAD_WORDS) {
      // The three word address provided is invalid
      print('BadWords: ${error!.message}');
    } else if (error == What3WordsError.INTERNAL_SERVER_ERROR) {
      // Server Error
      print('InternalServerError: ${error!.message}');
    } else if (error == What3WordsError.NETWORK_ERROR) {
      // Network Error
      print('NetworkError: ${error!.message}');
    } else {
      print('${error!.code} : ${error.message}');
    }
  }
}
10
likes
140
points
1.27k
downloads

Publisher

verified publisherwhat3words.com

Weekly Downloads

A Dart library to use the what3words v3 API. This library can either be used in native Dart or Flutter applications

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

chopper, os_detect

More

Packages that depend on what3words