Search packages, repositories and app categories

Package detailsv0.0.1

ip_geolocation_api

A dart package to flutter or dart projects to get your geolocation data from your IP

30-day downloads
10
Likes
14
Pub points
40

Install package

flutter pub add ip_geolocation_api

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Dart package for Flutter and Dart projects that retrieves geolocation data based on an IP address. It simplifies the process of obtaining location details such as country, city, latitude, longitude, and ISP by making API calls to a geolocation service. Designed for ease of integration, it supports both web and mobile platforms, enabling developers to enhance user experience with location-aware features. The package is lightweight and efficient, ideal for applications requiring basic geolocation without GPS access.

Use cases

  • Fetching user location from IP address
  • Enhancing regional content delivery
  • Improving security through IP-based checks
  • Displaying localized weather or language
  • Tracking user locations for analytics

Key features

  • Simple IP-to-location lookup
  • Supports web and mobile platforms
  • Lightweight and easy to integrate
  • Returns detailed geolocation data
  • Built-in error handling

Suitable for

  • Mobile apps needing location insights
  • Web applications with regional logic
  • Security tools detecting suspicious IPs
  • Apps with localization needs
  • Developers seeking quick geolocation without GPS

Considerations

  • Relies on external API availability
  • Accuracy depends on IP database quality
  • May require API key for high usage
  • Not suitable for precise real-time tracking
  • Limited to IP-based geolocation, not device GPS

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

ip_geolocation_api

A dart package to get your geolocation data from your IP

Example

import 'dart:convert';

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

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

class _HomePageState extends State<HomePage> {
  String text = '';
  GeolocationData geolocationData;

  @override
  void initState() {
    super.initState();
    this.getIp();
  }

  Future<void> getIp() async {
    geolocationData = await GeolocationAPI.getData();
    if (geolocationData != null) {
      setState(() {
        text = geolocationData.ip;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(text),
              FlatButton(
                  onPressed: () {
                    if (geolocationData != null) {
                      setState(() {
                        text = jsonEncode(geolocationData.toJson());
                      });
                    }
                  },
                  child: Text("toJSON"))
            ],
          ),
        ),
      ),
    );
  }
}

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.