Code Monkey home page Code Monkey logo

flutter_wifi_connect's Issues

ios xcode12 compilation issues

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:

  • platform version in podspec file is pointing to 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())
  • missing argument labels
    /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)
  • return type in 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
  • unhandled exception from 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!

Compilation error.

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

Deprecated version of the Android embedding.

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.

PlatformException

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?

Will not build on Android Studio

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.

flutter_wifi_connect

Unhandled Exception: MissingPluginException(No implementation found for method activateWifi on channel
flutter_wifi_connect)

android suggestions

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.

  • on Android API < 29 support connection without requiring location permissions.

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)
  • implement disconnect method on Android

Some 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.

  • issue with wpa2/wpa3 on Android 11

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!

[Question] How to use the plugin effectively?

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:

  1. Can you connect to a normal wifi?

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.

  1. If it is only for IOT devices, can you communicate with them via Sockets?

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.

compilation error

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.