title: How to Read Data From Firebase Realtime Database?
body: <p>I am Trying to read the data from the firebase realtime Database in my Flutter app and assign it to model class but, i am getting the following error in console.</p>
  <pre><code>E/flutter ( 9052): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: Class 'List&lt;dynamic&gt;' has no instance getter 'keys'.
  E/flutter ( 9052): Receiver: _List len:3
  E/flutter ( 9052): Tried calling: keys
  E/flutter ( 9052): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
  E/flutter ( 9052): #1      _MyHomePageState.initState.&lt;anonymous closure&gt; (package:app/main.dart:64:27)
  E/flutter ( 9052): #2      _rootRunUnary (dart:async/zone.dart:1362:47)
  E/flutter ( 9052): #3      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
  E/flutter ( 9052): #4      _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
  E/flutter ( 9052): #5      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
  E/flutter ( 9052): #6      Future._propagateToListeners (dart:async/future_impl.dart:733:32)
  E/flutter ( 9052): #7      Future._completeWithValue (dart:async/future_impl.dart:539:5)
  E/flutter ( 9052): #8      _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
  E/flutter ( 9052): #9      Query.once (package:firebase_database/src/query.dart)
  E/flutter ( 9052): &lt;asynchronous suspension&gt;
  </code></pre>
  <p>Following is the Code I have Done So far</p>
  <ol>
  <li><p><img src="https://i.stack.imgur.com/VvDvL.png" alt="firebase database data" /></p>
  </li>
  <li><p><strong>Employee Class</strong></p>
  </li>
  </ol>
  <pre><code>class Employee {
  
    final String id;
    final String name;
    final String email;
    final String emp_id;
  
    const Employee({this.id,this.name,this.email,this.emp_id});
  }
  </code></pre>
  <ol start="3">
  <li><strong>Main Class</strong></li>
  </ol>
  <pre><code>import 'dart:convert';
  
  import 'package:firebase_database/firebase_database.dart';
  import 'package:flutter/material.dart';
  import 'package:google_fonts/google_fonts.dart';
  import 'package:shimmer/shimmer.dart';
  import 'Employee.dart';
  
  
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
  
        home: MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
   List &lt;Employee&gt; myAllData = [];
     
    @override
    void initState() {
    super.initState();
      DatabaseReference ref = FirebaseDatabase.instance.reference();
      ref.child('employee').once().then((DataSnapshot snap){
      var keys = snap.value.keys;
        var data = snap.value;
          for (var key in keys){
            Employee d = new Employee(
              id : data [key]['id'],
              name : data[key]['name'],
              email : data[key]['email'],
              emp_id: data[key]['emp_id']
            );
            myAllData.add(d);
          }
  
  
        setState(() {
         print('Length : ${myAllData.length}');
        });
      });
  
     }
    @override
    Widget build(BuildContext context) {
  
      return Scaffold(
        );
    }
  
  }
  </code></pre>
  <p>I am unable to figure out what i am doing wrong, please help me to resolve the issue</p>