android_flutter_wifi

Creator: coderz1093

Last updated:

Add to Cart

Description:

android flutter wifi

android_flutter_wifi #
Android Wifi plugin for flutter apps
Getting Started #
This plugin allows Flutter apps to get available Wifi access point list where you can get almost all
the information about AP accessing to WifiNetwork object. This plugin works only for Android. Apple
does not allow devs to maniplute wifi.
Note :- This plugin requires the location permission to auto enable the wifi if android version is
above 9.0. Please enable your GPS
Android : - Add below Permissions to your manifist.xml file -
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.hardware.wifi" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
copied to clipboard
This plugin depends on permission_handler package so
please import this package in yaml file
permission_handler: ^9.2.0
copied to clipboard
Initialize plugin to request location permissions inti() method return boolean

true if permission is granted
false is permission is denied

init() async {
await AndroidFlutterWifi.init();
}
copied to clipboard
Get Wifi access point list Object WifiNetwork contains almost every inforamtion avaiable on AP

Signal level

5 is maximum
0 is minimum



getWifiList() async {
List<WifiNetwork> wifiList = await AndroidFlutterWifi.getWifiScanResult();
if(wifiList.isNotEmpty){
WifiNetwork wifiNetwork = wifiList[0];
print('Name: ${wifiNetwork.ssid}');
}
}
copied to clipboard
Check if connection is fast or slow

Returns true if connection is fast
Returns false if connection is slow

isConnectionFast() {
print(AndroidFlutterWifi.isConnectionFast());
}
copied to clipboard
Check your connection type

Return 2 types of connection WI-FI or Cellular

getConnectionType() {
print(AndroidFlutterWifi.getConnectionType());
}
copied to clipboard
Get information about your wifi connection

ActiveWifiNetwork object contains every available information like

IP address,
Name
SSID
MAC Addess
etc



getActiveWifiNetwork() async {
ActiveWifiNetwork activeWifiNetwork = await AndroidFlutterWifi.getActiveWifiInfo();
}
copied to clipboard
Enable Wifi
static Future<void> enableWifi() async {
await _channel.invokeMethod(_ENABLE_WIFI_CALL);
}
copied to clipboard
Disable Wifi
static Future<void> disableWifi() async {
await _channel.invokeMethod(_DISABLE_WIFI_CALL);
}
copied to clipboard
Check if WI-FI is enable on your device

Returns true if WIFI is enabled
Return false is WIFI is disabled

static Future<bool> isWifiEnabled() async {
bool isWifiEnabled = await _channel.invokeMethod(_IS_WIFI_ENABLED_CALL);
return isWifiEnabled;
}
copied to clipboard
Get DHCP information
getDhcpInfo() async {
DhcpInfo dhcpInfo = await AndroidFlutterWifi.getDhcpInfo();
String ipString = AndroidFlutterWifi.toIp(dhcpInfo.gateway!);
print('Gateway: ${ipString}');
print('Formed ip: ${formedIp}');
}
copied to clipboard
Connect to a specific network with SSID & Password
void connectionTest() async {
String ssid = '';
String password = '';
if (ssid.isEmpty) {
throw ("SSID can't be empty");
}
if (password.isEmpty) {
throw ("Password can't be empty");
}
debugPrint('Ssid: $ssid, Password: $password');
///Return boolean value
///If true then connection is success
///If false then connection failed due to authentication
var result = await AndroidFlutterWifi.connectToNetwork(ssid, password);

debugPrint('---------Connection result-----------: ${result.toString()}');

}
copied to clipboard
IMPORTANT #

If your ip address is not well formed or it is reversed you can call this method to get well formed IP address

String formedIp = AndroidFlutterWifi.getFormedIp(ipString);
copied to clipboard
Get all saved wifi networks in your device #
List<ConfiguredNetwork> list =
await AndroidFlutterWifi.getConfiguredNetworks();
for (var element in list) {
debugPrint('Network id: ${element.networkId}');
}
copied to clipboard
Forget network by passing SSID #
ActiveWifiNetwork activeWifiNetwork = await AndroidFlutterWifi.getActiveWifiInfo();
var result = await AndroidFlutterWifi.forgetWifiWithSSID(activeWifiNetwork.ssid!);
copied to clipboard
Connect to pre-configured network #
var result = await AndroidFlutterWifi.connectToNetworkWithSSID('Xartic_85AC9C_5G');
debugPrint('Connection result: ${result.toString()}');
copied to clipboard
This project is a starting point for a Flutter
plug-in package, a specialized package that includes
platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter, view our
online documentation, which offers tutorials, samples, guidance on
mobile development, and a full API reference.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.