diff --git a/lib/group_domain_implementation/lib/src/accessors/firestore_course_member_accessor.dart b/lib/group_domain_implementation/lib/src/accessors/firestore_course_member_accessor.dart index ac1de887e..a0f066567 100644 --- a/lib/group_domain_implementation/lib/src/accessors/firestore_course_member_accessor.dart +++ b/lib/group_domain_implementation/lib/src/accessors/firestore_course_member_accessor.dart @@ -9,9 +9,9 @@ import 'dart:async'; import 'dart:developer'; +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:group_domain_models/group_domain_accessors.dart'; import 'package:group_domain_models/group_domain_models.dart'; -import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:sharezone_common/helper_functions.dart'; import 'package:sharezone_common/references.dart'; import 'package:user/user.dart'; @@ -38,10 +38,15 @@ class FirestoreCourseMemberAccessor extends CourseMemberAccessor { List membersData = []; void update() { - streamController.add(List.of(membersData) - ..addAll(joinedUsersData.where((joinedUser) => - membersData.where((it) => it.id == joinedUser.id).isEmpty) ?? - [])); + streamController.add( + List.of(membersData) + ..addAll( + joinedUsersData.where( + (joinedUser) => + membersData.where((it) => it.id == joinedUser.id).isEmpty, + ), + ), + ); } final subscription2 = _firestore @@ -73,8 +78,12 @@ class FirestoreCourseMemberAccessor extends CourseMemberAccessor { final subscription = _memberReference(courseID) .snapshots() .map((snapshot) => snapshot.docs - .map((docSnap) => - MemberData.fromData(docSnap.data(), id: docSnap.id)) + .map( + (docSnap) => MemberData.fromData( + docSnap.data() as Map, + id: docSnap.id, + ), + ) .toList()) .listen((newData) { membersData = newData; @@ -92,11 +101,15 @@ class FirestoreCourseMemberAccessor extends CourseMemberAccessor { Stream streamSingleMember(String courseID, String memberID) { // ignore:close_sinks final StreamController streamController = StreamController(); - MemberData joinedUsersData; - MemberData membersData; + MemberData? joinedUsersData; + MemberData? membersData; void update() { - streamController.add(membersData ?? joinedUsersData); + if (membersData != null) { + streamController.add(membersData!); + } else if (joinedUsersData != null) { + streamController.add(joinedUsersData!); + } } final subscription2 = _firestore @@ -110,13 +123,13 @@ class FirestoreCourseMemberAccessor extends CourseMemberAccessor { if (docSnapshot.exists) { joinedUsersData = MemberData.create( id: docSnapshot.id, - role: docSnapshot.data()['powerLevel'] == 'owner' + role: docSnapshot.data()!['powerLevel'] == 'owner' ? MemberRole.owner : MemberRole.creator, user: AppUser.create(id: docSnapshot.id).copyWith( - name: docSnapshot.data()['name'], + name: docSnapshot.data()!['name'], typeOfUser: enumFromString( - TypeOfUser.values, docSnapshot.data()['typeOfUser'])), + TypeOfUser.values, docSnapshot.data()!['typeOfUser'])), ); } else { joinedUsersData = null; @@ -129,7 +142,9 @@ class FirestoreCourseMemberAccessor extends CourseMemberAccessor { final subscription = _memberReference(courseID) .doc(memberID) .snapshots() - .map((docSnap) => MemberData.fromData(docSnap.data(), id: docSnap.id)) + .map((docSnap) => MemberData.fromData( + docSnap.data() as Map, + id: docSnap.id)) .listen((newData) { membersData = newData; update(); diff --git a/lib/group_domain_implementation/lib/src/accessors/firestore_school_class_member_accessor.dart b/lib/group_domain_implementation/lib/src/accessors/firestore_school_class_member_accessor.dart index 00362aca2..f70a2d8c0 100644 --- a/lib/group_domain_implementation/lib/src/accessors/firestore_school_class_member_accessor.dart +++ b/lib/group_domain_implementation/lib/src/accessors/firestore_school_class_member_accessor.dart @@ -6,9 +6,9 @@ // // SPDX-License-Identifier: EUPL-1.2 +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:group_domain_models/group_domain_accessors.dart'; import 'package:group_domain_models/group_domain_models.dart'; -import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:sharezone_common/references.dart'; class FirestoreSchoolClassMemberAccessor extends SchoolClassMemberAccessor { @@ -27,8 +27,10 @@ class FirestoreSchoolClassMemberAccessor extends SchoolClassMemberAccessor { return _memberReference(schoolClassID).snapshots().map( (snapshot) => snapshot.docs .map( - (docSnap) => - MemberData.fromData(docSnap.data(), id: docSnap.id), + (docSnap) => MemberData.fromData( + docSnap.data() as Map, + id: docSnap.id, + ), ) .toList(), ); @@ -37,7 +39,10 @@ class FirestoreSchoolClassMemberAccessor extends SchoolClassMemberAccessor { @override Stream streamSingleMember(String schoolClassID, String memberID) { return _memberReference(schoolClassID).doc(memberID).snapshots().map( - (snapshot) => MemberData.fromData(snapshot.data(), id: snapshot.id), + (snapshot) => MemberData.fromData( + snapshot.data() as Map, + id: snapshot.id, + ), ); } } diff --git a/lib/group_domain_implementation/pubspec.yaml b/lib/group_domain_implementation/pubspec.yaml index e716f0dc6..27a386ac0 100644 --- a/lib/group_domain_implementation/pubspec.yaml +++ b/lib/group_domain_implementation/pubspec.yaml @@ -12,7 +12,7 @@ version: 0.0.1 publish_to: none environment: - sdk: ">=2.10.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: group_domain_models: