iamshaunjp / iamshaunjp/flutter-firebase

issues with database.dart cant user List data in stream

Open
#31 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
586
Forks
427
PR merge metrics
No merged PRs in 30d

Description

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>> get userData {
return userDataCollection.snapshots()
.map(_userDataListFromSnapshot);
}
}

lib/screens/home/home.dart:16:32: Error: The argument type 'Stream>>' can't be assigned to the parameter type 'Stream>'.
- '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> 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);
^

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.