andyduke / styled_text_package

Text widget with formatted text using tags. Makes it easier to use formatted text in multilingual applications.
https://pub.dev/packages/styled_text
BSD 3-Clause "New" or "Revised" License
74 stars 48 forks source link

find.text does not find the text #60

Open tuanthyme opened 1 year ago

tuanthyme commented 1 year ago
testWidgets('renders text', (tester) async {
      await tester.pumpWidget(
        MaterialApp(
          home: StyledText(text: 'data'),
        ),
      );

      expect(find.text('data', findRichText: true), findsOneWidget);
    });

The above test as well as test for "StyledText.selectable" fails trying to find any Text, EditableText, or RichText. This makes unit testing based on strings rendered difficult.

andyduke commented 1 year ago

I think this is because StyledText parses the input text (xml) asynchronously.

Maatteogekko commented 1 year ago

@tuanthyme Does it work if await tester.pumpAndSettle() is called before the find?

andyduke commented 1 year ago

I think it might work 50% of the time as a side effect. There is no exact way to wait until the end of the render.

danallen88 commented 1 month ago

Just running into this myself now. Wondering if there are suggestions on how to handle this? Or if this can be fixed by the library so that the text parsing is not asynchronous?

andyduke commented 1 month ago

@tuanthyme @danallen88 Text parsing is now synchronous in StyledText starting from version 9.0.0. While this version is in beta status, you can already try to see if this solves your difficulties.