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

[syncfusion_calendar] richTextWidget is RichText is not true is shown up #2234

Open
NoirFreedom opened this issue Dec 31, 2024 · 5 comments
Open
Labels
calendar Calendar component open Open

Comments

@NoirFreedom
Copy link

Bug description

I'm experiencing this error when building just the default SFCalendar, showing up when the header is shown.

Flutter version: 3.24.3 Stable channel
imported package version: 28.1.35

I'm building it for flutter web.

And the error of richTextWidget is RichText is not true is shown up, details as below:

Steps to reproduce

  1. Run it
  2. it's just shown up

Code sample

Code sample
Size _getTextWidgetWidth(
    String text, double height, double width, BuildContext context,
    {TextStyle? style}) {

  /// Create new text with it style.
  final Widget richTextWidget = Text(
    text,
    style: style,
    maxLines: 1,
    softWrap: false,
    textDirection: TextDirection.ltr,
    textAlign: TextAlign.left,
  ).build(context);

  RenderParagraph? renderObject;
  if (richTextWidget is! RichText) {
    assert(richTextWidget is RichText);
  } else {
    /// Create and layout the render object based on allocated width and height.
    renderObject = richTextWidget.createRenderObject(context);
  }
  renderObject!.layout(BoxConstraints(
    minWidth: width,
    maxWidth: width,
    minHeight: height,
    maxHeight: height,
  ));

  /// Get the size of text by using render object.
  final List<TextBox> textBox = renderObject.getBoxesForSelection(
      TextSelection(baseOffset: 0, extentOffset: text.length));
  double textWidth = 0;
  double textHeight = 0;
  for (final TextBox box in textBox) {
    textWidth += box.right - box.left;
    final double currentBoxHeight = box.bottom - box.top;
    textHeight = textHeight > currentBoxHeight ? textHeight : currentBoxHeight;
  }

  /// 10 padding added for text box(left and right side both as 5).
  return Size(textWidth + 10, textHeight + 10);
}

Screenshots or Video

Screenshots / Video demonstration Screenshot 2024-12-31 at 3 47 24 PM

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

Web

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.96.0)
[✓] Connected device (4 available)
[✓] Network resources
@VijayakumarMariappan VijayakumarMariappan added calendar Calendar component open Open labels Jan 2, 2025
@Kaviyarasansf4298
Copy link

Kaviyarasansf4298 commented Jan 3, 2025

Hi @NoirFreedom ,

We have checked the mentioned scenario and tried to replicate the reported issue as richTextWidget is RichText is not true is showing up in the SfCalendar with version 28.1.37. However, we were unable to reproduce it on our end. Please review the attached sample, and if you are still encountering the issue, we kindly request that you replicate it in the attached sample and provide us with additional details about the specific scenario in which the issue occurs. This will help us assist you more effectively.
GitHub_2234.zip

Regards,
Kaviyarasan Arumugam.

@LavanyaGowtham2021 LavanyaGowtham2021 added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels Jan 3, 2025
@NoirFreedom
Copy link
Author

NoirFreedom commented Jan 6, 2025

hmm..first of all, I used 28.1.35 version at first, this was because when I run my project with 28.1.37 version, it occurs the error below

`Error: The method 'withValues' isn't defined for the class 'Color'.
 - 'Color' is from 'dart:ui'.
Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
        ? selectionColor!.withValues(alpha: 0.4)`

after that I upgraded my flutter version to 28.1.37, but still richTextWidget is RichText is not true was shown up..
like the screenshot below I attached

Screenshot 2025-01-06 at 12 56 11 PM

@Kaviyarasansf4298
Copy link

Kaviyarasansf4298 commented Jan 6, 2025

Hi @NoirFreedom ,

In the current implementation of the SfCalendar, we’ve noticed that the_getTextWidgetWidth function checks if the created widget is of type RichText. If it is not, it triggers an assertion as richTextWidget will always be a RichText. To ensure we're addressing correctly, we kindly request that you confirm whether the correct type of data has been provided in your implementation. Additionally, we request that you replicate it in the sample and provide us with more details along with demo regarding the specific scenario in which you are encountering this issue. This will help us to assist you more effectively.

GitHub_2234.zip

Regards,
Kaviyarasan Arumugam

@NoirFreedom
Copy link
Author

NoirFreedom commented Jan 7, 2025

Hi @Kaviyarasansf4298

I initially thought the issue was with my code, but after reproducing your sample code, it worked fine without any assertion errors. To investigate further, I copied and pasted my code into the sample project, and it also worked without issues.

Given that my code works fine in the sample project, are there any other factors or clues that might lead to this assertion error in my actual project? Could it be related to project-specific configurations or dependencies?


I upgraded my flutter version, and this is the result of flutter doctor
[✓] Flutter (Channel stable, 3.27.1, on macOS 14.5 23F79 darwin-arm64, locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.96.0)
[✓] Connected device (4 available)
[✓] Network resources

@LavanyaGowtham2021 LavanyaGowtham2021 added open Open and removed waiting for customer response Cannot make further progress until the customer responds. labels Jan 13, 2025
@NoirFreedom
Copy link
Author

Hi @Kaviyarasansf4298

I initially thought the issue was with my code, but after reproducing your sample code, it worked fine without any assertion errors. To investigate further, I copied and pasted my code into the sample project, and it also worked without issues.

Given that my code works fine in the sample project, are there any other factors or clues that might lead to this assertion error in my actual project? Could it be related to project-specific configurations or dependencies?

I upgraded my flutter version, and this is the result of flutter doctor [✓] Flutter (Channel stable, 3.27.1, on macOS 14.5 23F79 darwin-arm64, locale en-KR) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.3) [✓] VS Code (version 1.96.0) [✓] Connected device (4 available) [✓] Network resources

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

No branches or pull requests

4 participants