Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
Empty device can be add even if we quit the page and come back
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Albisson authored and Damien Albisson committed Jun 3, 2024
1 parent e9db099 commit 675d415
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/after_setup_pages/hunt_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class _HuntPageState extends State<HuntPage> {
const Text('Hunt'),
ElevatedButton(
onPressed: () {
print(widget._platformConfig.devices);
widget._platformConfig.devices.insert(
0,
DeviceConfig(
Expand Down
15 changes: 9 additions & 6 deletions lib/after_setup_pages/platform_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ class _PlatformPageState extends State<PlatformPage> {
var jsonObject = json.decode(pt);

if (jsonObject.containsKey("devices")) {
Map<dynamic, dynamic> store = jsonObject["devices"]["store"];
setState(() {
_deviceStore = store;
});
if (jsonObject.containsKey("store")) {
Map<dynamic, dynamic> store = jsonObject["devices"]["store"];
setState(() {
_deviceStore = store;
});
}
}
}

Expand Down Expand Up @@ -161,15 +163,16 @@ class _PlatformPageState extends State<PlatformPage> {
@override
void initState() {
super.initState();

// subscribe to info and atts ?
_platformConfig.devices = [];
Future.delayed(const Duration(milliseconds: 1), initializeMqttSubscription);
}

@override
Widget build(BuildContext context) {
print("!!!!!!!!!!! ${_platformConfig.devices.length}");

return Scaffold(
appBar: getAppBar("Platform"),
body: Center(
Expand Down

0 comments on commit 675d415

Please sign in to comment.