ios_network_info 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

ios_network_info #

This is a Dart plugin package for accessing network information from Flutter. This is an iOS-only plugin.

Usage #

import 'package:ios_network_info/ios_network_info.dart';

getNetworkInfo() async {
  bssid = await IosNetworkInfo.bssid;
  ssid = await IosNetworkInfo.ssid;
}

For a working example app, see the example directory

Limitations #

This Flutter plugin relies on CNCopyCurrentNetworkInfo which on iOS 12 and later requires the com.apple.developer.networking.wifi-info entitlement.

(CNCopyCurrentNetworkInfo) To use this function in iOS 12 and later, enable the Access WiFi Information capability in Xcode. For more information, see Access WiFi Information Entitlement.

Requesting this entitlement successfully is only available if you joined the Apple Developers Program.

Add "Access WiFi Information" capability to your app (otherwise, you'll receive nulls).

Don't forget to enable

Note: "Access WiFi Information" capability is not the same as "Wireless Accessory Configuration".

Alternatives #

  • connectivity plugin lets you get the WiFi SSID (wifiName). After my pull request is merged, you can also get the BSSID of the current WiFi network

GitHub #

The source code is available on GitHub smaho-gmbh/ios_network_info.

This Flutter plugin is created by the SMAHO engineering team.

0.1.2 #

  • Make package homepage more helpful

0.1.1 #

  • Improve docs, READMEs
  • Clean up Android code (which only fails, but anyway...)

0.1.0 #

  • Initial release
  • Support for current network BSSID and SSID (wifi name)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ios_network_info/ios_network_info.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _bssid = 'Unknown BSSID';
  String _ssid = 'Unknown SSID';

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

  fetchAll() {
    fetchBssid();
    fetchSsid();
  }

  fetchBssid() async {
    String bssid;
    try {
      bssid = await IosNetworkInfo.bssid;
    } on PlatformException {
      bssid = 'Failed to get WiFi BSSID.';
    }
    setBssid(bssid);
  }

  setBssid(String bssid) {
    if (!mounted) return;
    setState(() {
      _bssid = bssid;
    });
  }

  fetchSsid() async {
    String ssid;
    try {
      ssid = await IosNetworkInfo.ssid;
    } on PlatformException {
      ssid = 'Failed to get WiFi SSID.';
    }
    setSsid(ssid);
  }

  setSsid(String ssid) {
    if (!mounted) return;
    setState(() {
      _ssid = ssid;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.black87,
          title: const Text('ios_network_info'),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.refresh),
              onPressed: fetchAll,
            ),
          ],
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'SSID: $_ssid',
                style: Theme.of(context).textTheme.headline,
              ),
              SizedBox(height: 12),
              Text(
                'BSSID: $_bssid',
                style: Theme.of(context).textTheme.headline,
              ),
              SizedBox(height: 20),
              Text('ios_network_info'),
              Text('Flutter plugin example'),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ios_network_info: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ios_network_info/ios_network_info.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
73
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:ios_network_info/ios_network_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:ios_network_info/ios_network_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:ios_network_info/ios_network_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:ios_network_info/ios_network_info.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [ios_network_info] that is in a package requiring null.

Maintenance suggestions

Package is getting outdated. (-26.58 points)

The package was last published 66 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test