diff --git a/README.md b/README.md index 86732f8..629bf3f 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,61 @@ Add ios/Info.plist NSLocationWhenInUseUsageDescription Used to Location's Info for Using Beacon when In Use. ``` +## Usage +``` +late Stream? _stream; + +@override + void initState() { + _stream = EsptouchSmartconfig.run(widget.ssid, widget.bssid, + widget.password, widget.deviceCount, widget.isBroadcast); + super.initState(); + } + +@override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + Navigator.of(context).pop(_results); + }), + backgroundColor: Colors.red, + title: Text( + 'Task', + ), + ), + body: Container( + child: StreamBuilder( + stream: _stream, + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.hasError) { + return error(context, 'Error in StreamBuilder'); + } + switch (snapshot.connectionState) { + case ConnectionState.active: + _results.add(snapshot.data!); + return resultList(context, ConnectionState.active); + case ConnectionState.none: + return noneState(context); + case ConnectionState.done: + if (snapshot.hasData) { + _results.add(snapshot.data!); + return resultList(context, ConnectionState.done); + } else + return noneState(context); + case ConnectionState.waiting: + return waitingState(context); + } + }, + ), + ), + ); + } + +``` + ## Reference