Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji make exception in TyperAnimatedTextKit #118

Closed
eunjin3786 opened this issue Oct 10, 2020 · 5 comments
Closed

Emoji make exception in TyperAnimatedTextKit #118

eunjin3786 opened this issue Oct 10, 2020 · 5 comments

Comments

@eunjin3786
Copy link

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
'dart:ui/painting.dart': Failed assertion: line 3968: '': is not true.

@awhitford
Copy link
Collaborator

Can you please provide some sample code and a stack trace? The above assertion is not very much to go on.

@eunjin3786
Copy link
Author

@awhitford

Thankyou 👍

class SettingsWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: EdgeInsets.all(10),
        child: Center(
          child: TyperAnimatedTextKit(
            text: ["hello world ☺️👍🍥️"],
            isRepeatingAnimation: true,
            speed: Duration(milliseconds: 60)
          ),
        )
    );
  }
}

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
'dart:ui/painting.dart': Failed assertion: line 3968: '': is not true.
The relevant error-causing widget was:
TyperAnimatedTextKit file:///Users/kakao/Documents/onion_family/lib/widget/main/settings_widget.dart:14:18
The following RenderObject was being processed when the exception was fired: RenderParagraph#a695f relayoutBoundary=up3
parentData: (can use size)
constraints: BoxConstraints(0.0<=w<=394.0, 0.0<=h<=792.0)
size: Size(114.0, 27.0)
textAlign: start
textDirection: ltr
softWrap: wrapping at box width
overflow: clip
locale: en_US
maxLines: unlimited
text: TextSpan
inherit: false
color: label(color = Color(0xff000000), darkColor = Color(0xffffffff), resolved by: Builder)
debugLabel: label
color: Color(0xff000000)
darkColor: Color(0xffffffff)
last resolved: Builder
family: .SF Pro Text
size: 17.0
letterSpacing: -0.4
decoration: TextDecoration.none
"hello world ☺️👍?"
RenderObject: RenderParagraph#a695f relayoutBoundary=up3
parentData: (can use size)
constraints: BoxConstraints(0.0<=w<=394.0, 0.0<=h<=792.0)
size: Size(114.0, 27.0)
textAlign: start
textDirection: ltr
softWrap: wrapping at box width
overflow: clip
locale: en_US
maxLines: unlimited
text: TextSpan
inherit: false
color: label(color = Color(0xff000000), darkColor = Color(0xffffffff), resolved by: Builder)
debugLabel: label
color: Color(0xff000000)
darkColor: Color(0xffffffff)
last resolved: Builder
family: .SF Pro Text
size: 17.0
letterSpacing: -0.4
decoration: TextDecoration.none
"hello world ☺️👍?"
════════════════════════════════════════════════════════════════════════════════════════════════════

@awhitford
Copy link
Collaborator

This looks like the offending widget:

return Text(
_texts[_index]['text'].substring(0, offset),
style: widget.textStyle,
textAlign: widget.textAlign,
);

I see this message:

flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following ArgumentError was thrown during performLayout():
flutter: Invalid argument(s): string is not well-formed UTF-16
flutter:
flutter: The relevant error-causing widget was:
flutter:   Text
flutter:   file:///Users/anthony/flutter/.pub-cache/hosted/pub.dartlang.org/animated_text_kit-2.3.0/lib/src/typer.dart:145:26
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      ParagraphBuilder.addText (dart:ui/text.dart:2178:7)
flutter: #1      TextSpan.build (package:flutter/src/painting/text_span.dart:208:15)
flutter: #2      TextPainter.layout (package:flutter/src/painting/text_painter.dart:560:14)
flutter: #3      RenderParagraph._layoutText (package:flutter/src/rendering/paragraph.dart:497:18)
flutter: #4      RenderParagraph._layoutTextWithConstraints (package:flutter/src/rendering/paragraph.dart:520:5)

This looks like a known issue: dart-lang/sdk#35798

This reminds me of the Flutter 1.22 announcement where they mentioned the characters package.

The String Length of '☺️👍🍥️' is not 3, but actually 7. However, it is only 3 Characters.

The solution is to rework the widget to use the new Characters package, rather than use String.substring.

@awhitford
Copy link
Collaborator

Note that the Typewriter has the same flaw and will also need to be fixed, but let's wait for the Typer fix to be reviewed first.

aagarwal1012 added a commit that referenced this issue Oct 12, 2020
Added support for Emoji characters to the Typer. Resolves #118.
@awhitford
Copy link
Collaborator

PR #122 addresses Typewriter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants