h3_core 1.0.1
h3_core: ^1.0.1 copied to clipboard
Dart/Flutter bindings for the H3 geospatial indexing library. Uses dart:ffi on native platforms, h3-js on web.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:h3_core/h3_core.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late String _cellHex;
late LatLng _center;
late int _resolution;
@override
void initState() {
super.initState();
final sf = LatLng(37.7749295, -122.4194155);
final cell = latLngToCell(sf, 9);
_cellHex = cell.toHex();
_center = cellToLatLng(cell);
_resolution = getResolution(cell);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('H3 Core Demo')),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('H3 v${H3Version.native}'),
const SizedBox(height: 16),
Text('Cell: $_cellHex'),
Text('Resolution: $_resolution'),
Text(
'Center: ${_center.lat.toStringAsFixed(6)}, ${_center.lng.toStringAsFixed(6)}',
),
],
),
),
),
);
}
}