From 116a9a349e11e059eaeddea88cd29d585bb9bfa0 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Sun, 5 Nov 2023 06:01:37 +0200 Subject: Working with the DB. Changes to be committed: modified: lib/main.dart --- client_app_flutter/lib/main.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client_app_flutter/lib/main.dart b/client_app_flutter/lib/main.dart index 31bc250..5fd98b4 100644 --- a/client_app_flutter/lib/main.dart +++ b/client_app_flutter/lib/main.dart @@ -65,6 +65,8 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { FirebaseDatabase database = FirebaseDatabase.instance; + // final ref = FirebaseDatabase.instance.ref(); + int _counter = 0; void _incrementCounter() { @@ -74,8 +76,16 @@ class _MyHomePageState extends State { // 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++; - _counter = database.hashCode; + _counter++; + // final snapshot = await ref.child('temperature').get(); + final snapshot = database.ref().child('temperature').get(); + // if (snapshot.exists) { + // print(snapshot.value); + // var _counter = snapshot.value; + // } else { + // print('No data available.'); + // } + // // _counter = ref.child('temperature').get() as int; }); } -- cgit v1.2.3