Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues with database.dart cant user List data in stream #31

Open
refat47 opened this issue Aug 4, 2021 · 0 comments
Open

issues with database.dart cant user List data in stream #31

refat47 opened this issue Aug 4, 2021 · 0 comments

Comments

@refat47
Copy link

refat47 commented Aug 4, 2021

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:googletestconnection/models/userData.dart';

class DatabaseService{

final String uid;
DatabaseService ({this.uid});
//collection Refferences

final CollectionReference userDataCollection = FirebaseFirestore.instance.collection('userData');

Future updateUserData(String sugars, String name, int strength) async {
return await userDataCollection.doc(uid).set({
'sugars': sugars,
'name': name,
'strength': strength,
});
}
//User data collection
List _userDataListFromSnapshot(QueryDocumentSnapshot snapshot) {
return snapshot.get('doc').map((doc) {
return UserDataList(
name: doc.data['name'] ?? '',
strength: doc.data['strength'] ?? 0,
sugars: doc.data['sugars'] ?? '0'
);

});

}
//get user profile data

Stream<QueryDocumentSnapshot<List>> get userData {
return userDataCollection.snapshots()
.map(_userDataListFromSnapshot);
}
}

lib/screens/home/home.dart:16:32: Error: The argument type 'Stream<QueryDocumentSnapshot<List>>' can't be assigned to the parameter type 'Stream<QuerySnapshot>'.

  • 'Stream' is from 'dart:async'.
  • 'QueryDocumentSnapshot' is from 'package:cloud_firestore/cloud_firestore.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.4.0/lib/cloud_firestore.dart').
  • 'List' is from 'dart:core'.
  • 'UserDataList' is from 'package:googletestconnection/models/userData.dart' ('lib/models/userData.dart').
  • 'QuerySnapshot' is from 'package:cloud_firestore/cloud_firestore.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.4.0/lib/cloud_firestore.dart').
  • 'Object' is from 'dart:core'.
    value: DatabaseService().userData,
    ^
    lib/services/database.dart:35:10: Error: The argument type 'List Function(QueryDocumentSnapshot)' can't be assigned to the parameter type 'QueryDocumentSnapshot<List> Function(QuerySnapshot)'.
  • 'List' is from 'dart:core'.
  • 'UserDataList' is from 'package:googletestconnection/models/userData.dart' ('lib/models/userData.dart').
  • 'QueryDocumentSnapshot' is from 'package:cloud_firestore/cloud_firestore.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.4.0/lib/cloud_firestore.dart').
  • 'Object' is from 'dart:core'.
  • 'QuerySnapshot' is from 'package:cloud_firestore/cloud_firestore.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.4.0/lib/cloud_firestore.dart').
    .map(_userDataListFromSnapshot);
    ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant