Viewing version 1.0.0. Open the latest package page.

dart_polylabel2

1.0.0

A fast algorithm for finding polygon pole of inaccessibility. Useful for optimal placement of a text label on a polygon.

Download archive

Readme

dart_polylabel2

A fast algorithm for finding polygon pole of inaccessibility. Useful for optimal placement of a text label on a polygon.

Dart port of mapbox's polylabel algorithm. Thanks to beroso's original port (polylabel) for inspiration.

This has a few changes from polylabel, which make it not backwards compatible:

  • No usage of 'dart:math's Point
    • It's been described as legacy since Feb 2024 in Dart/Flutter, and will be deprecated in future
    • This reduces internal & external casting and usage of generic types (which are inefficient), which has increased performance
    • It was overkill for the simple 2D Cartesian coordinate container needed
  • Uses newer Dart lanaguage features

Usage

import 'package:dart_polylabel2/dart_polylabel2.dart';

final polygon = [[(x: 0, y: 0), (x: 1, y: 0), (x: 1, y: 1), (x: 0, y: 1), (x: 0, y: 0)]];
final (point: (:x, :y), :distance) = polylabel(polygon);
Changelog

Changelog

[1.0.0] - 2025/06/10

  • Initial version

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'dart_polylabel2:1.0.0'
pubspec.yaml
name: dart_polylabel2
description: >-
  A fast algorithm for finding polygon pole of inaccessibility. 
  Useful for optimal placement of a text label on a polygon.
version: 1.0.0
repository: https://github.com/JaffaKetchup/dart_polylabel2
issue_tracker: https://github.com/JaffaKetchup/dart_polylabel2/issues

funding:
  - https://github.com/sponsors/JaffaKetchup

environment:
  sdk: ">=3.6.0 <4.0.0"

dependencies:
  collection: ^1.18.0
  meta: ^1.11.0

dev_dependencies:
  lints: ^6.0.0
  test: ^1.24.9

Version history

VersionPublishedArchiveSHA-256
1.0.0Cached · Upstream SHA-256 matchedDownload7eeab15c…57adc6

Dependencies

collection "^1.18.0"

meta "^1.11.0"