DEV Community

Yvan COYAUD
Yvan COYAUD

Posted on

StreamBuilder on a list of objects.

Hello everyone,
I would like to know how it is possible to make a StreamBuilder on a list of objects.

class UnSpan {
    UnSpan(String texte,{double fontSize=20,
                FontWeight bold=FontWeight.normal}){
            this.texte =texte;
            this.fontSize =fontSize;
            this.bold =FontWeight.normal;}
    String texte="";
    double fontSize=20;
    FontWeight bold=FontWeight.normal;
}
List<UnSpan> listSpans = [];
Enter fullscreen mode Exit fullscreen mode

After initializing this list, I would like to be able to do a StreamBuilder on this list to be able to display each span in a RichText

RichText(
  text: TextSpan(
    text:'',
    children:[
      streamBuilder(
-------- _That's where I don't know._
--------
        itemBuilder: (BuildContext context, int index) {
          TextSpan(text: listspans[index].texte,
                   style:TextStyle(
                     fontWeight:listSpans[index].bold,
                     fontSize:listSpans[index].fontSize))

Enter fullscreen mode Exit fullscreen mode

Can someone please help me
Thank you in advance
YC

Top comments (0)