A simplified version of the Wifi Iot package. ( This is a wrapper for the https://pub.dev/packages/wifi_iot package )
Here's the github repository link: https://github.com/p32929/simply_wifi_flutter Feel free to star, fork and send pull requests. You're welcome.
Sharing with your friends is just one click away from here
If you like my works and want to support me/my works, feel free to support or donate. My payment details can be found here: https://p32929.github.io/SendMoney2Me/
First of all:
- You need to set the
compileSdkVersion
andtargetSdkVersion
to28
inandroid/app/build.gradle
( or you may call it the App Level Gradle file ) - It won't work properly in v29 ( Android 10 or above )
SimplyWifi.init();
You MUST call the init() function before calling any other functions in this package. By initializing, you will also be asked for the location permission.
SimplyWifi.turnOnWifi();
SimplyWifi.turnOffWifi();
List<WifiNetwork> _wifiNetworks = SimplyWifi.getListOfWifis();
int indexNumber = 0;
String passwordOfTheWifi = "I-dont-know";
SimplyWifi.connectWifiByIndex(indexNumber, password: passwordOfTheWifi);
After you call the getListOfWifis(), it gives you a
List
of WiFis around you. Now, if you want to connect any of the wifi, from the list, you can just pass the index number of theList
element & it will connect the wifi. Notice that, if the Wifi is secured, you have to pass the password parameter.
String wifiName = "WifiName";
SimplyWifi.connectWifiByName(wifiName, password: passwordOfTheWifi);
Notice that, if the Wifi is secured, you have to pass the password parameter.
SimplyWifi.disconnectWifi();
SimplyWifi.forgetWifiByWifiName(wifiName);
SimplyWifi.forgetWifiByIndex(index)
All the functions ( except SimplyWifi.disconnectWifi()
) returns a future. So, you can call them like this:
SimplyWifi.anyFunctionMentionedABove(necessaryParameters).then((value){
// do something when done
})
or
await SimplyWifi.anyFunctionMentionedAbove(necessaryParameters);
// do something when done
I hope, you will enjoy using the library. Feel free to contribute codes.
MIT License
Copyright (c) 2020 Fayaz Bin Salam
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.