flutterlatexformulaflutter-tex

Flutter_tex generate list of TeXViewDocuments dynamically


so for example I have a list of Strings in Latex like:

List<String> example = [
    LatexString1,
    LatexString2,
    LatexString3,
    LatexString4
  ];

But this list is created dynamically case by case, so I don't know, how long the list will be (and what the content of the list will be).

What I want now is a created list of that LatexStrings on the smartphone with Flutter_tex, but I really don't know how to do it. Is it even possible? Cause normally for cases like that I use List.View.seperated widget with an itemBuilder which works pretty well for non latex-Strings.
So also I can not put a List.View Widget into a TexView Widget.

Perhaps for a better imagination: I want a list like the "Hallo"s in the picture just with Math Formulas given by Latex :)

enter image description here

So if someone could help me with that problem, that would be really really nice.
Thanks a lot and kind regards!


Solution

  • You're probably looking for TeXViewGroup. It has a children property that you can set by using the map method on example. So, it would look something like:

    TeXView(
        child: TeXViewGroup(
           children: example.asMap().entries.map((entry) {
               return TeXViewGroupItem(
                   id: entry.key.toString(), 
                   child: TeXViewDocument(entry.value)
               );
           }).toList().cast<TeXViewGroupItem>(),
           onTap: ((id){})
        )
    )
    

    You might need to edit that snippet as per your needs, but here is the official usage example: See from line 125

    In the example, the map is directly used because the list items already have unique values (every child of the TeXViewGroup widget must have a unique id), but since your's doesn't, you'll need to use .asMap().entries and later type caste it as shown in the above snippet.