Flutter Firebase Realtime Database

  • Firebase Realtime database

1.Write:-

In firebase, getInstance() method is used to retrieve the instance thenreference the location you want to write.setValue() method is used to set the value to the particular reference.
FirebaseDatabase database = FirebaseDatabase.getInstance();DatabaseReference myRef = database.getReference("message");myRef.setValue("Hello, World!");


2.Read:-

The FirebaseDatabase give us a lot of methods and listener, to verify when all database was updated, when a specific child was updated and etc.
DataSnapshot : A DataSnapshot instance contains all the data from a firebase database for a particular node. Any time when you want to read Database data, you receive the data as a datasnapshot.
DataSnapshot will be returned in the listeners methods that you attach to the DatabaseReference:
addValueEventListener(ValueEventListener),{onDataChange(),onCancelled()}
addChildEventListener(ChildEventListener),
onCancelled(DatabaseError error)// This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.
onChildAdded(DataSnapshot snapshot, String previousChildName) // triggered when a new child is added to the location to which this listener was added.
onChildChanged(DataSnapshot snapshot, String previousChildName) //  triggered when the data at a child location has changed.
onChildMoved(DataSnapshot snapshot, String previousChildName)// triggered when a child location's priority changes.
onChildRemoved(DataSnapshot snapshot)// triggered when a child is removed from the location to which this listener was addedaddListenerForSingleValueEvent(ValueEventListener).

  • Check it
 https://medium.com/@tattwei46/flutter-how-to-do-crud-with-firebase-rtdb-ce61e3ce53a

  • Firebase database crud operation with listview
https://grokonez.com/flutter/flutter-firebase-database-example-firebase-database-crud-listview

  • Firebase realtime series on Youtube
https://www.youtube.com/watch?v=I3EC96lTJB4&list=PLVjuFl8H_-p_f2mgxQ2DeqV9cZbe7ceZQ

  • Most important about firebase realitme database
https://grokonez.com/flutter/flutter-firebase-database-example-firebase-database-crud-listviewhttps://stackoverflow.com/questions/52246790/flutter-firebase-database-and-listview-builder-issue



Comments

Post a Comment