location_reader 0.0.7 copy "location_reader: ^0.0.7" to clipboard
location_reader: ^0.0.7 copied to clipboard

A Flutter package for retrieving and handling location-related data, including current location, reverse geocoding, Firebase integration, location permission management, and nearby location queries.

example/main.dart

import 'package:flutter/material.dart';
import 'package:location_reader/config/di/register_location_service_get_it_di.dart';
import 'package:location_reader/location_reader.dart'; // Import the location_reader package
import 'package:get_it/get_it.dart';

void main() {
  // Register dependencies
  registerLocationServiceGetItDi();

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Location Reader Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const LocationScreen(),
    );
  }
}

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

  @override
  State<LocationScreen> createState() => _LocationScreenState();
}

class _LocationScreenState extends State<LocationScreen> {
  String locationMessage = "Fetching location...";

  @override
  void initState() {
    super.initState();
    _getLocation();
  }

  Future<void> _getLocation() async {
    final locationRepository = GetIt.I<ICurrentLocationRepository>();
    final result = await locationRepository.getCurrentLocation();

    result.fold(
      (failure) {
        setState(() {
          locationMessage = "Error fetching location: ${failure.toString()}";
        });
      },
      (location) {
        setState(() {
          locationMessage =
              "Current Location: \nLat: ${location.lat}, Lon: ${location.lon}";
        });
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Location Reader Example')),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Text(
            locationMessage,
            textAlign: TextAlign.center,
            style: const TextStyle(fontSize: 20),
          ),
        ),
      ),
    );
  }
}
2
likes
130
points
183
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for retrieving and handling location-related data, including current location, reverse geocoding, Firebase integration, location permission management, and nearby location queries.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bloc, cloud_firestore, dartz, equatable, exception_type, firestore_db_impl, flutter, flutter_bloc, fluttertoast, geo_lat_lon, geocoding, geolocator, get_it_di_global_variable, i_tdd, json_annotation, navigation_without_context, provider

More

Packages that depend on location_reader