Randomize / Shuffle ListView displaying Firebase Documents from filtered Query

Actions & Logic
Resolved

I have a ListView which is displaying documents from a Firebase Query... but I can't seem to figure out how to get it to Randomize (shuffle) the results each time.

What have you tried so far?

Tried following this thread this from Serge Middendorf which works for shuffling lists, but the query does not send back a list (at-least that's accessible), it sends back documents.

Serge confirmed his action requires a list... but only individual documents are an option here.

I also explored copying the code from the ListView widget to make a custom widget with adding shuffle to it. But figuring out all the parameters and dependencies etc to get it to work/pass the code check (it just gets stuck) is beyond my FF knowledge.\

This seems to be the main bit of the code... 'reverse: true,' lives in there... 🤷‍♂️

List<TaskRecord> listViewTaskRecordList = snapshot.data!;
return ListView.separated(
padding: EdgeInsets.symmetric(vertical: 10.0),
reverse: true,
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: listViewTaskRecordList.length,
separatorBuilder: (_, __) => SizedBox(height: 10.0),
itemBuilder: (context, listViewIndex) {
final listViewTaskRecord = listViewTaskRecordList[listViewIndex];

Is there any way to add a step in between that would modify the widget code, or intercept the list it gets back from the query to re-order it?

Did you check FlutterFlow's Documentation for this topic?
Yes
1
5 replies