I just refactored a method slightly by removing some of the widget as another stateless widget named TransformableSSLVI (transformable saved searches list view item)
I return the extracted TransformableSSLVI widget from a method searchesListItemBuilder in SavedSearches
class SavedSearches extends StatefulWidget {
SavedSearches({Key? key}) : super(key: key);
@override
_SavedSearchesState createState() => _SavedSearchesState();
}
class _SavedSearchesState extends State<SavedSearches> {
Widget searchesListItemBuilder(BuildContext context, index, searchesList) {
llog.i(searchesList[index].toString());
return ...
child: TransformableSSLVI(
...
searchesList: searchesList,
initSearches: initSearches,
)
...
}
which gets the new searchesList values from a streambuilder snapshot
Widget build(BuildContext context) {
return StreamBuilder<List<Map>>(
stream: SavedSearchesStream.searchesStream,
builder: (BuildContext context,
AsyncSnapshot<List<Map>> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return searchesListItemBuilder(context,
index, snapshot.data);
},
);
...
When the searchesList[index] logs in the method searchesListItemBuilder, it shows values, but in TransformableSSLVI, it is showing searchesList is empty, I thought especially because it is a method calling with arguments TransformableSSLVI should update with searchesList when the streamBuilder receives a new value. Why does it hold on to the null value?