flutter_tex icon indicating copy to clipboard operation
flutter_tex copied to clipboard

TeXView Widget takes more space than needed at the bottom in ListView.builder

Open aeaevo opened this issue 1 year ago • 0 comments

Situation: I am building a maximum of 6 TeXView instances in a ListView.builder.

Expected behaviour: One TeXView below the next one in a vertically scrollable ListView.

Actual behaviour: A List is created with TeXView instances, but in some cases the TeXView takes more space after the actually rendered content than needed. It seems like being approx. double the space needed (in this example the TeXView is wrapped with a teal-colored Container). This issue occurs irregularly with the exact same LaTeX code. I also feel the issue happens when scrolling slowly rather than fast

ListView.builder(
  itemCount: answers.length,
  itemBuilder: (context, index) {

  String parsedText = parseTeX(answers[index]);

  return Container(
    color: Colors.teal,
    child: TeXView(
        fonts: const [
          TeXViewFont(
              fontFamily: 'Poppins',
              src: 'fonts/Poppins-Regular.ttf'),
        ],
        child: TeXViewColumn(
          children: [
            for (var text in parsedText) ...[
              if (text.trim().isNotEmpty) ...[
                TeXViewDocument(text.trim(),
                    style: TeXViewStyle(
                      padding: const TeXViewPadding.only(
                          top: 5, bottom: 5),
                      backgroundColor: Colors.transparent,
                      contentColor: colorWhite,
                      fontStyle: TeXViewFontStyle(
                          fontSize: 12,
                          fontFamily: 'Poppins'),
                      textAlign:
                          containsTextNotEnclosedInMath(
                                  text)
                              ? TeXViewTextAlign.left
                              : TeXViewTextAlign.center,
                    )),
              ]
            ]
          ],
        )),
    )
  });

aeaevo avatar Jul 12 '23 08:07 aeaevo