geolocation_info_ip 0.0.1 copy "geolocation_info_ip: ^0.0.1" to clipboard
geolocation_info_ip: ^0.0.1 copied to clipboard

Este package permite obtener informacion de la ip donde el dispositivo se encuentra conectado a internet.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String ip = '';
  Future<void> cargar() async {
    GeolocationModel apiGeo = await ApiGeo.getGeolocation();
    setState(() {
      ip = apiGeo.ip;
    });
    print(apiGeo);
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Plugin example app'),
      ),
      body: Center(
        child: Text('IP: ${ip}'),
      ),
    );
  }
}
2
likes
150
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Este package permite obtener informacion de la ip donde el dispositivo se encuentra conectado a internet.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter

More

Packages that depend on geolocation_info_ip