summaryrefslogtreecommitdiff
path: root/client_app_flutter
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-11-05 08:15:28 +0200
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-11-05 08:15:28 +0200
commit0fd8bce6926751eaa4487b76ad709460dbb6751d (patch)
tree17afa7d78297e3b6bd6b455881f095bf3455b0b0 /client_app_flutter
parent093d847606d5fa7d613417593b3201400ec8cd17 (diff)
Prepared for presentation and meeting the deadline (no way).
Changes to be committed: modified: LINKS.md modified: TODO.md modified: client_app_flutter/lib/main.dart new file: images/DHT-temp-hum-sensor.jpg new file: images/DSM501A-air-dust-smoke-sensor.jpg renamed: images/ESP32 Pinout Diagram.png -> images/ESP32-Pinout-Diagram-board.png renamed: images/ESP32-Pinout-1.jpg -> images/ESP32-Pinout-board.jpg renamed: images/ESP32 Specs.png -> images/ESP32-Specs.png new file: images/MQ135-gas-sensor.jpg new file: images/SBC-NodeMCU-ESP32-01-board.png new file: images/cpp-logo.png new file: images/dart-game-logo.png new file: images/dart-kotlin-swift-logos.png new file: images/dart-logo.png new file: images/firebase-logo.png new file: images/flutter-logo.png new file: images/python-logo.png new file: presentation/sent_markdown_presentation
Diffstat (limited to 'client_app_flutter')
-rw-r--r--client_app_flutter/lib/main.dart22
1 files changed, 19 insertions, 3 deletions
diff --git a/client_app_flutter/lib/main.dart b/client_app_flutter/lib/main.dart
index 8502127..957b125 100644
--- a/client_app_flutter/lib/main.dart
+++ b/client_app_flutter/lib/main.dart
@@ -64,7 +64,8 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
- FirebaseDatabase database = FirebaseDatabase.instance;
+ // FirebaseDatabase database = FirebaseDatabase.instance;
+ // DatabaseReference ref = FirebaseDatabase.instance.ref().child('temperature');
// final ref = FirebaseDatabase.instance.ref();
int _counter = 0;
@@ -76,7 +77,14 @@ class _MyHomePageState extends State<MyHomePage> {
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
- _counter++;
+ // ref.onValue.listen(
+ // (event) {
+ // setState(() {
+ // _counter = event.snapshot.value as int;
+ // });
+ // },
+ // );
+ // _counter++;
// final snapshot = await ref.child('temperature').get();
// final snapshot = database.ref().child('temperature').get();
// if (snapshot.exists) {
@@ -93,7 +101,15 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
- //
+
+ DatabaseReference ref = FirebaseDatabase.instance.ref().child('temperature');
+ ref.onValue.listen(
+ (event) {
+ setState(() {
+ _counter = event.snapshot.value as int;
+ });
+ },
+ );
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.