I am developing an app in flutter that lists available wifi devices and connects to the selected on. I am using Wifi.connection of wifi package of flutter to connect to the selected network. It returns WifiState.error everytime i try to connect to the wifi.
This is the code in which i try to connect to the wifi.
import 'package:flutter/material.dart';
import 'package:wifi/wifi.dart';
Future<Null> connection() async {
print('funciton called');
Wifi.connection('Mohit1', 'mohit@123').then((v) {
print(v);
});
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: FlatButton(
onPressed: ()=> connection(),
child: Text('Connect'),
),
),
);
}
}
I am kinda stuck with this, as it is just a single API. i dont know what to look for regarding this error. Thanks in advance.