local_ip 0.0.2 copy "local_ip: ^0.0.2" to clipboard
local_ip: ^0.0.2 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _ipStr = '0.0.0.0';

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


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(_ipStr),
          centerTitle: true,
        ),
        body: Center(
          child: RaisedButton(
            child: Text("GetIp"),
            onPressed: _getIp,
          ),
        ),
      ),
    );
  }

  _getIp() async {
    var ip = await LocalIp.ip;
    print(ip);
    setState(() {
      _ipStr = ip;
    });
  }
}
0
likes
30
pub points
7%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on local_ip