-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Expected behavior (required)
When a view passes a Document reference to another view, I expect the other view to successfully load the document from the reference.
Current behavior (required)
I get an infinite spinner and the data never loads. No error is displayed either.
To Reproduce (required)
- I set up a first view with a ListView showing documents in a collection.
- I set up a second view which will show the selected document.
- In the first view, I set up the ListViewItem to navigate to the second view, and pass the document reference.
- In the second view, I set up the Scaffold to load a document based on the passed document reference.
- In the Scaffold, I have a Text widget which displays a field from the loaded document.
I am basically following the steps at:
- https://docs.flutterflow.io/data-and-backend/backend-query/document-from-reference
- https://www.youtube.com/watch?v=hkBWVwr7yXQ
Context (required)
I am trying to load a document from a passed reference.
Screenshots / recordings
Another user in the Discord channel was able to reproduce the bug: https://discord.com/channels/845826746582695976/845826825992929321/1027793029517545493.
To work around this issue, the solution they shared, which works for me too, is to pass the Document itself. Then in the second view, load the document again using the passed Document's reference.
I tried setting up two Text widgets, one using the passed reference, and the other reading the reference from the passed document. The first one shows an infinite spinner. The second one shows the data. I expected both to just show the same data (ie "bakeree").
The resulting code is nearly identical and seems correct:
StreamBuilder<CompaniesRecord>(
stream: CompaniesRecord.getDocument(widget.companyRef!),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
width: 50,
height: 50,
child: CircularProgressIndicator(
color: FlutterFlowTheme.of(context).primaryColor,
),
),
);
}
final textCompaniesRecord = snapshot.data!;
return Text(
textCompaniesRecord.name!,
style: FlutterFlowTheme.of(context).bodyText1,
);
},
),
StreamBuilder<CompaniesRecord>(
stream: CompaniesRecord.getDocument(
widget.passedCompany!.reference),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
width: 50,
height: 50,
child: CircularProgressIndicator(
color: FlutterFlowTheme.of(context).primaryColor,
),
),
);
}
final textCompaniesRecord = snapshot.data!;
return Text(
textCompaniesRecord.name!,
style: FlutterFlowTheme.of(context).bodyText1,
);
},
),
Your environment
- Version of FlutterFlow used:
- on a Mac Mini M1 in Chrome 105.0.5195.125 (arm64).