0

I am struggling with getting the data from my 'Firebase'. The 'print(mUsers)' are getting me the users from 'Firebase', so it is working up to that point. So I think my problem is with this: 'final users = UserModel.fromRTDB(Map<String, dynamic>.from(value));'

I see there is many ways to do this, but I have used this guide: https://www.youtube.com/watch?v=sXBJZD0fBa4&t=1649s

Here is my StreamBuilder:

StreamBuilder(
            stream: _database
                .child('brukere')
                .limitToLast(10)
                .onValue,
            builder: (context, snapshot){
              final tilesList = <ListTile>[];
              if(snapshot.hasData) {
                final mUsers = Map<String, dynamic>.from(
                    (snapshot.data! as DatabaseEvent).snapshot.value as Map );
                tilesList.addAll(mUsers.values.map((value) {
                  print(mUsers);

                  final users =
                      UserModel.fromRTDB(Map<String, dynamic>.from(value));
                  return ListTile(
                      onTap: () {
                      print(users.name);
                    },
                      isThreeLine: true,
                      leading: Icon (Icons.person),
                      title: Text(users.name),
                      trailing: Row(
                        mainAxisSize: MainAxisSize.min,
                        children:<Widget> [
TB AS
  • 27
  • 7

1 Answers1

0

my mistake. My firebase children was not identical to my 'UserModel' class.

TB AS
  • 27
  • 7