flutter_esptouch 0.0.9
flutter_esptouch: ^0.0.9 copied to clipboard
flutter_esptouch
import 'dart:async';
import 'package:flutter_esptouch/flutter_esptouch.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
Map wifiInfo = Map();
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> getWifiInfo() async {
Map? result = await EsptouchFlutter.wifiInfo;
setState(() {
wifiInfo = result ?? Map();
});
}
Future<void> initPlatformState() async {
bool platformVersion;
try {
platformVersion = await EsptouchFlutter.connectWifi(
wifiInfo['mSsid'],
wifiInfo['mBssid'],
"admin123",
) ??
false;
} on PlatformException {}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
InkWell(
onTap: () {
getWifiInfo();
print("initPlatformState");
},
child: Container(
color: Colors.red,
child: Container(
height: 100,
width: 100,
child: Text('wifi info ${this.wifiInfo}=='),
),
),
),
SizedBox(
height: 100,
),
InkWell(
onTap: () {
initPlatformState();
print("initPlatformState");
},
child: Container(
color: Colors.red,
child: Center(
child: Text(
'initPlatformState on: $_platformVersion\n ${wifiInfo}'),
),
),
),
],
)),
);
}
}