flutter_esptouch 0.0.9 copy "flutter_esptouch: ^0.0.9" to clipboard
flutter_esptouch: ^0.0.9 copied to clipboard

flutter_esptouch

example/lib/main.dart

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}'),
                  ),
                ),
              ),
            ],
          )),
    );
  }
}
0
likes
125
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

flutter_esptouch

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_esptouch

Packages that implement flutter_esptouch