location_manager 0.0.4 copy "location_manager: ^0.0.4" to clipboard
location_manager: ^0.0.4 copied to clipboard

PlatformiOS

Plugin for handling location updates.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:location_manager/models/location_model.dart';
import 'package:location_manager_example/locator_handler.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    final locationHandler = LocationHandler();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Example Location Manager'),
        ),
        body: StreamBuilder<LocationModel>(
          stream: locationHandler.stream,
          builder: (context, AsyncSnapshot<LocationModel> snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return const CircularProgressIndicator.adaptive();
            }
            if (snapshot.hasError) {
              return Text(snapshot.error.toString());
            }
            if (!snapshot.hasData) {
              return const Text("No data");
            }
            final item = snapshot.data!;

            return Center(
              child: Padding(
                padding: const EdgeInsets.all(30.0),
                child: Table(
                  children: [
                    TableRow(children: [
                      const Text("Latitude"),
                      Text(item.latitude.toString()),
                    ]),
                    TableRow(children: [
                      const Text("Longitude"),
                      Text(item.longitude.toString()),
                    ]),
                    TableRow(children: [
                      const Text("Accuracy"),
                      Text(item.accuracy.toString()),
                    ]),
                    TableRow(children: [
                      const Text("Altitude"),
                      Text(item.altitude.toString()),
                    ]),
                    TableRow(children: [
                      const Text("Speed"),
                      Text(item.speed.toString()),
                    ]),
                  ],
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}
4
likes
110
pub points
32%
popularity

Publisher

unverified uploader

Plugin for handling location updates.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

either_dart, flutter, plugin_platform_interface

More

Packages that depend on location_manager