title: Flutter code to display the firebase data in listview or in listbuilder
body: <p>I am developing an app in which I need to display all the lecturer details which is stored in Firebase using <code>list_view</code>. I have used <code>list_builder</code> for that. I am getting the same data in all the list view that means all tile contains same lecturer id.</p>
  
  <p><img src="https://i.stack.imgur.com/BF4EG.png" alt="enter image description here"> </p>
  
  <p><img src="https://i.stack.imgur.com/1DLWU.png" alt="enter image description here"></p>
  
  <p>i tried to upload screenshot but i could not upload it</p>
  
  <p><strong>output:</strong>
  <strong><em>1: variable exist :</em></strong> </p>
  
  <pre><code>{LEC02: {EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC02, NAME: VIGNESH, POSITION: LECTURER, PASSWORD: LEC02, PHOTO: , QUALIFICATION: BCOM, DOJ: 2018-12-24 00:00:00.000}, LEC04: {EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC04, NAME: KARTHIK, POSITION: LECTURER, PASSWORD: LEC04, PHOTO: , QUALIFICATION: MCOM, DOJ: 2018-12-26 00:00:00.000}}
  </code></pre>
  
  <p><strong><em>2: variable key_id:</em></strong></p>
  
  <pre><code>(LEC02, LEC04, LECTURER 01, LEC03, LEC01)
  </code></pre>
  
  <p><strong><em>3: variable data:</em></strong></p>
  
  <pre><code>({EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC02, NAME: VIGNESH, POSITION: LECTURER, PASSWORD: LEC02, PHOTO: , QUALIFICATION: BCOM, DOJ: 2018-12-24 00:00:00.000}, {EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC04, NAME: KARTHIK, POSITION: LECTURER, PASSWORD: LEC04, PHOTO: , QUALIFICATION: MCOM, DOJ: 2018-12-26 00:00:00.000}, {EMAIL: , SEX: FEMALE, ADDRESS: , MOBILE: , ID: LECTURER 01, NAME: AA, POSITION: LECTURER, PASSWORD: LECTURER 01, PHOTO: , QUALIFICATION: KAAM, DOJ: 2018-12-25 00:00:00.000}, {EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC03, NAME: PRANEETH, POSITION: HOD, PASSWORD: LEC03, PHOTO: , QUALIFICATION: MCA, DOJ: 2018-12-25 00:00:00.000}, {EMAIL: , SEX: MALE, ADDRESS: , MOBILE: , ID: LEC01, NAME: NISHA, POSITION: LECTURER, PASSWORD: LEC01, PHOTO: , QUALIFICATION: MCOM, DOJ: 2018-12-26 00:00:00.000})
  </code></pre>
  
  <h3>Code</h3>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_database/firebase_database.dart';
  import 'dart:async';
  import 'package:firebase_database/ui/firebase_animated_list.dart';
  
  import '../slidelecturer.dart';
  import 'dart:convert';
  
  String lecturer_id,lecturer_name;
  bool hasdata=true;
  Map&lt;dynamic,dynamic&gt; exist;
  Iterable&lt;dynamic&gt;key_id,data;
  Widget body;
  
  
  final FirebaseDatabase database = FirebaseDatabase.instance;
  
  class viewlecturer extends StatefulWidget {
    @override
    _viewlecturerState createState() =&gt; _viewlecturerState();
  }
  
  class _viewlecturerState extends State&lt;viewlecturer&gt; {
  
   @override
   void initState(){
     print("hello");
  
    this.get_data();
  
   }
  
    @override
    Widget build(BuildContext context) {
      if(hasdata==false){
        body=new Container(
  
        child:Center(
          child: Text("LECTURER DOSE NOT EXIST",style: TextStyle(color: Colors.grey,fontWeight: FontWeight.bold,fontSize: 20),),
  
       ));
      }
       if(hasdata==true){
         body= new Container(
        child: ListView.builder(
           itemCount: exist==null?0:exist.length,
           itemBuilder: (BuildContext context,int index){
             return Card(
               child: new Text("${key_id}"),
  
             );
           },
  
         ),);}
  
      return body;
  
    }
  
  
     Future&lt;String&gt;get_data()async {
  
        database
            .reference()
            .child("NITTE/LECTURER").orderByValue()
            .once()
            .then((DataSnapshot snapshot) async {
              this.setState((){
                exist = snapshot.value;
              });
  
          if (exist == null) {
            setState(() {
              hasdata=false;      
                      });
  
              // confirmation();
          } else if (exist != null) {
            setState(() {
              hasdata=true; 
  
              key_id=exist.keys;
              data=exist.values;
  
            });
          }
        });
      }
    }
  </code></pre>