weplenish / flutter_wifi_connect Goto Github PK
View Code? Open in Web Editor NEWA flutter plugin to allow simple connection to wifi devices with the provided ssid or ssid prefix.
License: BSD 3-Clause "New" or "Revised" License
A flutter plugin to allow simple connection to wifi devices with the provided ssid or ssid prefix.
License: BSD 3-Clause "New" or "Revised" License
3 errors in flutter_wifi_connect\FlutterWifiConnectPlugin.kt: (317,5), (341,49), and (350.51): Smart cast to 'ConnectivityManager.NetworkCallback' is impossible because 'this.networkCallback' is a mutable property that could have been changed by this time.
Hello, I have a few question that I hoping someone can help me with.
flutter doctor
./flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[!] Android Studio (version 4.0)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (1 available)
Testing device: Samsung galaxy a70 (android 10) latest.
I am trying to use this library and I am not quite sure if I am using it effectively.
Questions:
I have tried to connect it to my home wifi and yielded this results:
FlutterWifiConnect.connectToSecureNetwork(ssid, password: WPA2)
It always connects (regardless if the password is correct or not) but always without internet connection.
FlutterWifiConnect.connect(ssid)
(Having open my wifi):
It always connects but without internet connection.
If I connect to a device that generates their own wifi (wifi is always without internet obviously) can I communicate with it using sockets?
I can manually connect to its wifi and talk to it using TCP sockets,
does the connection made by this plugin holds the same behaviour in order to automatize the wifi connection process?
Thank you very much in advance.
The plugin wifi_configuration
uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding.
Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding:
https://flutter.dev/go/android-plugin-migration.
Hi,
First, thanks for creating this plugins with minimal dependencies and using the latest Android APIs.
I found some issues while trying to use this plugin with Flutter 1.22.5 and xcode 12.3. The Swift code does not compile in my environment. Here are some of the problems:
8.0
instead of 11.0
/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_wifi_connect-0.0.4/ios/Classes/SwiftFlutterWifiConnectPlugin.swift:15:16: error: 'disconnect()' is only available in iOS 11 or newer
result(disconnect())
^
/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_wifi_connect-0.0.4/ios/Classes/SwiftFlutterWifiConnectPlugin.swift:15:16: note: add 'if #available' version check
result(disconnect())
/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_wifi_connect-0.0.4/ios/Classes/SwiftFlutterWifiConnectPlugin.swift:23:33: error: missing argument label 'arguments:' in call
let args = GetArgs(call.arguments)
connect
cannot be Bool
/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_wifi_connect-0.0.4/ios/Classes/SwiftFlutterWifiConnectPlugin.swift:77:42: error: cannot convert return expression of type 'Void' to return type 'Bool'
NEHotspotConfigurationManager.shared.apply(hotspotConfig) { [weak self] (error) in
GetArgs
I'm submitting a PR for your review which addresses the above issues. I tested it on iOS 14.2 and it seems to be working fine.
Thank you!
FlutterWifiConnectPlugin.kt: (350, 51): Smart cast to 'ConnectivityManager.NetworkCallback' is impossible, because 'this.networkCallback' is a mutable property that could have been changed by this time
Greetings everyone, I am trying to use the flutter wifi connect plugin, after many attempts I have not been successful
E/flutter (12076): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, NetworkCallback was not registered, null, java.lang.IllegalArgumentException: NetworkCallback was not registered E/flutter (12076): at android.net.ConnectivityManager.unregisterNetworkCallback(ConnectivityManager.java:4867) E/flutter (12076): at com.weplenish.flutter_wifi_connect.FlutterWifiConnectPlugin.connect(FlutterWifiConnectPlugin.kt:329) E/flutter (12076): at com.weplenish.flutter_wifi_connect.FlutterWifiConnectPlugin.onMethodCall(FlutterWifiConnectPlugin.kt:87) E/flutter (12076): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter (12076): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter (12076): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter (12076): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter (12076): at android.os.Handler.handleCallback(Handler.java:942) E/flutter (12076): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter (12076): at android.os.Looper.loopOnce(Looper.java:226) E/flutter (12076): at android.os.Looper.loop(Looper.java:313) E/flutter (12076): at android.app.ActivityThread.main(ActivityThread.java:8741) E/flutter (12076): at java.lang.reflect.Method.invoke(Native Method) E/flutter (12076): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) E/flutter (12076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) E/flutter (12076): ) E/flutter (12076): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) E/flutter (12076): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18) E/flutter (12076): <asynchronous suspension> E/flutter (12076): #2 FlutterWifiConnect.connect (package:flutter_wifi_connect/flutter_wifi_connect.dart:36:29) E/flutter (12076): <asynchronous suspension> E/flutter (12076): #3 _WifiListPageState.loaderInfo (package:micro_app_qi5_prototyping/presentation/pages/wifi_list_page.dart:34:13) E/flutter (12076): <asynchronous suspension> E/flutter (12076):
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
I added the bad permissions without success, could someone help me with this problem?
Hi,
First, thanks for creating this plugins with minimal dependencies and using the latest Android APIs.
I'd like to propose some improvements for the Android pluging.
wifiManager.connectionInfo.ssid
requires location permission, as an alternative the ssid could be obtained from info.getExtraInfo()
.
In the change receiver once could check both connectionInfo and extraInfo to cover both cases
result.success(wifiManager.connectionInfo.ssid == wifiConfiguration.SSID || info.getExtraInfo() == wifiConfiguration.SSID)
disconnect
method on AndroidSome application need to programatically disconnect from the peer to peer network and go back to the "default" WiFi/Internet connection. On API < 29 this could be done by calling wifiManager.disconnect()
, not the nicest but it works. On API >=29, it is a bit more involved but cleaner: unregister the network callback, and unbind the process from the network.
Note: on API >= 29, the network callback was being removed on onAvailable
which caused the connection to be disconnected as soon as it was connected.
On Android 11 (didn't test on Android 10) setWpa2Passphrase
and setWpa3Passphrase
are mutually exclusive. I propose to add an argument to explicitly ask for WPA3 when required by the application. The error is:
E/flutter (31808): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, only one of setIsEnhancedOpen, setWpa2Passphrase,setWpa3Passphrase, setWpa2EnterpriseConfig or setWpa3EnterpriseConfig can be invoked for network specifier, null, java.lang.IllegalStateException: only one of setIsEnhancedOpen, setWpa2Passphrase,setWpa3Passphrase, setWpa2EnterpriseConfig or setWpa3EnterpriseConfig can be invoked for network specifier
I'm submitting a PR with the above proposed changes. Happy to discuss them. Tested on Android 8.1 (Nexus 5X) and Android 11 (Pixel 2(
Thank you!
Many functions throw MissingPluginException
, like FlutterWifiConnect.deactivateWifi()
and such.
Unhandled Exception: MissingPluginException(No implementation found for method activateWifi on channel
flutter_wifi_connect)
Compilation error observed:
e: C:\Users\...\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_wifi_connect-0.0.7\android\src\main\kotlin\com\weplenish\flutter_wifi_connect\FlutterWifiConnectPlugin.kt: (317, 53): Smart cast to 'ConnectivityManager.NetworkCallback' is impossible, because 'this.networkCallback' is a mutable property that could have been changed by this time
e: C:\Users\...\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_wifi_connect-0.0.7\android\src\main\kotlin\com\weplenish\flutter_wifi_connect\FlutterWifiConnectPlugin.kt: (341, 49): Smart cast to '<no name provided>' is impossible, because 'networkCallback' is a mutable property that could have been changed by this time
e: C:\Users\...\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_wifi_connect-0.0.7\android\src\main\kotlin\com\weplenish\flutter_wifi_connect\FlutterWifiConnectPlugin.kt: (350, 51): Smart cast to 'ConnectivityManager.NetworkCallback' is impossible, because 'this.networkCallback' is a mutable property that could have been changed by this time
flutter_wifi_connect-0.0.7/android/src/main/kotlin/com/weplenish/flutter_wifi_connect/FlutterWifiConnectPlugin.kt: (227, 14): Using 'maxBy((T) -> R): T?' is an error. Use maxByOrNull instead.
I implemented this package to my project, seems sometimes work sometimes not.
Especially when I used to connect on system setting, it won't work on my project mobile app.
Hello Guys,
for now, this package will have new updates in:
https://pub.dev/packages/plugin_wifi_connect
me and "my team', are working together to continues this project, with permission of weplenish.
thank you and let's do it ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.