You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Delete in pubspec.yaml all the dependency_overrides section and in the dependencies section change network_info_plus: ^3.0.0.
Do flutter clean and flutter pub get and then run the app again.
Grant location permission make sure that you are connected to a WiFi,
Android:
iOs:
Code Sample
// Copyright 2017 The Chromium Authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.// ignore_for_file: public_member_api_docsimport'dart:async';
import'dart:developer'as developer;
import'dart:io';
import'package:flutter/foundation.dart';
import'package:flutter/material.dart';
import'package:flutter/services.dart';
import'package:network_info_plus/network_info_plus.dart';
// Sets a platform override for desktop to avoid exceptions. See// https://flutter.dev/desktop#target-platform-override for more info.void_enablePlatformOverrideForDesktop() {
if (!kIsWeb && (Platform.isWindows ||Platform.isLinux)) {
debugDefaultTargetPlatformOverride =TargetPlatform.fuchsia;
}
}
voidmain() {
_enablePlatformOverrideForDesktop();
runApp(constMyApp());
}
classMyAppextendsStatelessWidget {
constMyApp({Key? key}) :super(key: key);
// This widget is the root of your application.@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
title:'Flutter Demo',
theme:ThemeData(
primarySwatch:Colors.blue,
),
home:constMyHomePage(title:'Flutter Demo Home Page'),
);
}
}
classMyHomePageextendsStatefulWidget {
constMyHomePage({Key? key, this.title}) :super(key: key);
finalString? title;
@overrideState<MyHomePage> createState() =>_MyHomePageState();
}
class_MyHomePageStateextendsState<MyHomePage> {
String _connectionStatus ='Unknown';
finalNetworkInfo _networkInfo =NetworkInfo();
@overridevoidinitState() {
super.initState();
_initNetworkInfo();
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(
title:constText('NetworkInfoPlus example'),
),
body:Center(
child:Column(
mainAxisSize:MainAxisSize.min,
children: [
constText(
'Network info',
style:TextStyle(
fontSize:16,
fontWeight:FontWeight.bold,
),
),
constSizedBox(height:16),
Text(_connectionStatus),
],
)),
);
}
Future<void> _initNetworkInfo() async {
String? wifiName,
wifiBSSID,
wifiIPv4,
wifiIPv6,
wifiGatewayIP,
wifiBroadcast,
wifiSubmask;
try {
if (!kIsWeb &&Platform.isIOS) {
var status =await _networkInfo.getLocationServiceAuthorization();
if (status ==LocationAuthorizationStatus.notDetermined) {
status =await _networkInfo.requestLocationServiceAuthorization();
}
if (status ==LocationAuthorizationStatus.authorizedAlways ||
status ==LocationAuthorizationStatus.authorizedWhenInUse) {
wifiName =await _networkInfo.getWifiName();
} else {
wifiName =await _networkInfo.getWifiName();
}
} else {
wifiName =await _networkInfo.getWifiName();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi Name', error: e);
wifiName ='Failed to get Wifi Name';
}
try {
if (!kIsWeb &&Platform.isIOS) {
var status =await _networkInfo.getLocationServiceAuthorization();
if (status ==LocationAuthorizationStatus.notDetermined) {
status =await _networkInfo.requestLocationServiceAuthorization();
}
if (status ==LocationAuthorizationStatus.authorizedAlways ||
status ==LocationAuthorizationStatus.authorizedWhenInUse) {
wifiBSSID =await _networkInfo.getWifiBSSID();
} else {
wifiBSSID =await _networkInfo.getWifiBSSID();
}
} else {
wifiBSSID =await _networkInfo.getWifiBSSID();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi BSSID', error: e);
wifiBSSID ='Failed to get Wifi BSSID';
}
try {
wifiIPv4 =await _networkInfo.getWifiIP();
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi IPv4', error: e);
wifiIPv4 ='Failed to get Wifi IPv4';
}
try {
if (!Platform.isWindows) {
wifiIPv6 =await _networkInfo.getWifiIPv6();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi IPv6', error: e);
wifiIPv6 ='Failed to get Wifi IPv6';
}
try {
if (!Platform.isWindows) {
wifiSubmask =await _networkInfo.getWifiSubmask();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi submask address', error: e);
wifiSubmask ='Failed to get Wifi submask address';
}
try {
if (!Platform.isWindows) {
wifiBroadcast =await _networkInfo.getWifiBroadcast();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi broadcast', error: e);
wifiBroadcast ='Failed to get Wifi broadcast';
}
try {
if (!Platform.isWindows) {
wifiGatewayIP =await _networkInfo.getWifiGatewayIP();
}
} onPlatformExceptioncatch (e) {
developer.log('Failed to get Wifi gateway address', error: e);
wifiGatewayIP ='Failed to get Wifi gateway address';
}
setState(() {
_connectionStatus ='Wifi Name: $wifiName\n''Wifi BSSID: $wifiBSSID\n''Wifi IPv4: $wifiIPv4\n''Wifi IPv6: $wifiIPv6\n''Wifi Broadcast: $wifiBroadcast\n''Wifi Gateway: $wifiGatewayIP\n''Wifi Submask: $wifiSubmask\n';
});
}
}
Logs
It is too long for GitHub comment.
Flutter Doctor
[✓] Flutter (Channel stable, 3.3.6, on Microsoft Windows [Version 10.0.19044.2130], locale it-IT)
• Flutter version 3.3.6 on channel stable at C:\Users\ppanizza\Documents\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6928314d50 (2 weeks ago), 2022-10-25 16:34:41 -0400
• Engine revision 3ad69d7be3
• Dart version 2.18.2
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\ppanizza\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.3.32825.248
• Windows 10 SDK version 10.0.19041.0
[✓] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[✓] VS Code (version 1.73.0)
• VS Code at C:\Users\ppanizza\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.52.0
[✓] Connected device (4 available)
• DN2103 (mobile) • CMBY7LDQT4WC6HBI • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.2130]
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.88
• Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.35
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Checklist before submitting a bug
I Google'd a solution and I couldn't find it
I searched on StackOverflow for a solution and I couldn't find it
I read the README.md file of the plugin
I'm using the latest version of the plugin
All dependencies are up to date with flutter pub upgrade
I did a flutter clean
I tried running the example project
The text was updated successfully, but these errors were encountered:
This was already discussed in the past (e.g. here #986 (comment)), and some people tried to fix it, unfortunately the problem is that sometimes is impossible to differentiate between an SSID that indeed contains quotes than when the OS added the quotes.
The decision so far has been that the plugin should be in charge of returning what the OS returns, and the developers should be in charge of processing that data as they wish.
Platform
Android 12 and iOs 16.1
Plugin
network_info_plus
Version
3.0.1
Flutter SDK
3.3.6
Info
The method
getWifiName
behaves differently on Android and iOs:"
char.The following table resumes the behaviour of the method with different package versions (wifi name is WIFIxGUEST without
"
):Expected behaviour
Steps to reproduce
pubspec.yaml
all the dependency_overrides section and in the dependencies section changenetwork_info_plus: ^3.0.0
.Android:
iOs:
Code Sample
Logs
It is too long for GitHub comment.
Flutter Doctor
Checklist before submitting a bug
flutter pub upgrade
flutter clean
The text was updated successfully, but these errors were encountered: