'Error: The argument type 'Stream<PostsRecord>' can't be assigned to the parameter type 'Record'

New to flutter here (and coding in general) but have an issue that I cannot figure out to solve. I am navigating to a page based off of a variable and need to pass in a Record. However, I cannot figure out how to pass a Record from the reference already on the page (postReference). I only want to read this document if the button is pressed also. Using Firebase/Firestore as the backend. Any help is greatly appreciated!

Error

Error: The argument type 'Stream' can't be assigned to the parameter type 'PostsRecord'.

Code snippet below. I cannot figure out how to properly query the record to then pass to the Widget Builder.

class NotificationPageWidget extends StatefulWidget {
  const NotificationPageWidget({Key key}) : super(key: key);

  @override
  _NotificationPageWidgetState createState() => _NotificationPageWidgetState();
}

class _NotificationPageWidgetState extends State<NotificationPageWidget> {
  final scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffoldKey,
      appBar: AppBar(
        automaticallyImplyLeading: true,
        title: Text(
          'Notifications',
          style: FlutterFlowTheme.title1,
        ),
      ),
      body: SafeArea(
        child: Column(
          mainAxisSize: MainAxisSize.max,
          children: [
            Expanded(
              child: StreamBuilder<List<UserNotificationsRecord>>(
                stream: queryUserNotificationsRecord(
                  queryBuilder: (userNotificationsRecord) =>
                      userNotificationsRecord
                          .where('notifiedUsers',
                              arrayContains: currentUserReference)
                          .orderBy('notificationTime', descending: true),
                ),
                builder: (context, snapshot) {
                  // Customize what your widget looks like when it's loading.
                  if (!snapshot.hasData) {
                    return Center(
                      child: SizedBox(
                        width: 40,
                        height: 40,
                        child: CircularProgressIndicator(
                          color: FlutterFlowTheme.secondaryColor,
                        ),
                      ),
                    );
                  }
                  List<UserNotificationsRecord>
                      listViewUserNotificationsRecordList = snapshot.data;
                  return ListView.builder(
                    padding: EdgeInsets.zero,
                    scrollDirection: Axis.vertical,
                    itemCount: listViewUserNotificationsRecordList.length,
                    itemBuilder: (context, listViewIndex) {
                      final listViewUserNotificationsRecord =
                          listViewUserNotificationsRecordList[listViewIndex];
                      return InkWell(
                        onTap: () {
                          if (listViewUserNotificationsRecord.initialPageName == '/commentsPage') {
                            final postRef = PostsRecord.getDocument(listViewUserNotificationsRecord.postReference);
                            Navigator.push(context, MaterialPageRoute(builder: (context) => CommentsPageWidget(
                              activityRecord: postRef,
//This is where the error is occurring. Looking for a Record and not a Reference.
                            )
                            )
                            );
                          };
                        },
                      );
                    },
                  );
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source