yandex_geocoder 2.2.0-dev.1 copy "yandex_geocoder: ^2.2.0-dev.1" to clipboard
yandex_geocoder: ^2.2.0-dev.1 copied to clipboard

API to translate geographic coordinates into an address and vice versa

example/lib/main.dart

// ignore_for_file: public_member_api_docs

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final YandexGeocoder geo = YandexGeocoder(apiKey: 'Your Api Key');

  String address = 'null';
  String latLong = 'null';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Column(
              children: <Widget>[
                const Text('latitude: 37.597576, longitude: 55.771899'),
                Text(address),
              ],
            ),
            const SizedBox(height: 40),
            Column(
              children: <Widget>[
                const Text('address: Москва, 4-я Тверская-Ямская улица, 7'),
                Text(latLong.toString()),
              ],
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          address = 'null';
          latLong = 'null';
          setState(() {});

          final GeocodeResponse _address = await geo.getGeocode(
            ReverseGeocodeRequest(
              pointGeocode: (lat: 55.771899, lon: 37.597576),
            ),
          );
          address = _address.firstAddress?.formatted ?? 'null';

          final GeocodeResponse _latLong = await geo.getGeocode(
            DirectGeocodeRequest(
              addressGeocode: 'Москва, 4-я Тверская-Ямская улица, 7',
            ),
          );

          latLong = _latLong.firstPoint.toString();

          setState(() {});
        },
        child: const Icon(Icons.search),
      ),
    );
  }
}
44
likes
0
pub points
87%
popularity

Publisher

verified publishermadbrains.ru

API to translate geographic coordinates into an address and vice versa

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, http, json_annotation

More

Packages that depend on yandex_geocoder