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

[BUG] Html crash when used inside a DataTable #1459

Closed
EArminjon opened this issue Jan 30, 2025 · 18 comments · Fixed by #1460
Closed

[BUG] Html crash when used inside a DataTable #1459

EArminjon opened this issue Jan 30, 2025 · 18 comments · Fixed by #1460
Labels
bug Something isn't working

Comments

@EArminjon
Copy link
Contributor

Describe the bug:

Code throw when running Html inside DataTable widget.

HTML to reproduce the issue:

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

void main() async {
  runApp(
    const TestApp(),
  );
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: DataTable(
          columns: const <DataColumn>[
            DataColumn(
              label: Text('First column'),
            ),
            DataColumn(
              label: Text('Second column'),
            ),
          ],
          rows: <DataRow>[
            DataRow(
              cells: <DataCell>[
                DataCell(
                  Html(
                    data: 'Test',
                  ),
                ),
                const DataCell(
                  Text(
                    'Second cell',
                  ),
                ),
              ],
            ),
            const DataRow(
              cells: <DataCell>[
                DataCell(
                  Text('First cell'),
                ),
                DataCell(
                  Text(
                    'Second cell',
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Expected behavior:

Want to see my html

Screenshots:

Nothing appear, red screen

Device details and Flutter/Dart/flutter_html versions:

Stacktrace/Logcat

Performing hot restart...
Syncing files to device macOS...
Restarted application in 269ms.

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
The RenderCSSBox class does not implement "computeDryBaseline".


If you are not writing your own RenderBox subclass, then this is not
your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=2_bug.yml

The relevant error-causing widget was: 
  DataTable DataTable:file:///Users/earminjon/Documents/projects/bioderma/lib/main.dart:28:16
When the exception was thrown, this was the stack: 
#0      RenderBox.debugCannotComputeDryLayout.<anonymous closure> (package:flutter/src/rendering/box.dart:2154:9)
#1      RenderBox.debugCannotComputeDryLayout (package:flutter/src/rendering/box.dart:2158:6)
#2      RenderBox.computeDryBaseline (package:flutter/src/rendering/box.dart:2114:12)
#3      RenderBox._computeDryBaseline (package:flutter/src/rendering/box.dart:2071:50)
#4      _Baseline.memoize.ifAbsent (package:flutter/src/rendering/box.dart:1041:42)
#5      _LinkedHashMapMixin.putIfAbsent (dart:_compact_hash:636:23)
#6      _Baseline.memoize (package:flutter/src/rendering/box.dart:1042:18)
#7      RenderBox._computeWithTimeline (package:flutter/src/rendering/box.dart:1561:32)
#8      RenderBox._computeIntrinsics (package:flutter/src/rendering/box.dart:1539:26)
#9      RenderBox.getDryBaseline (package:flutter/src/rendering/box.dart:2055:36)
#10     _RenderScaledInlineWidget.computeDryBaseline (package:flutter/src/widgets/widget_span.dart:388:37)
...

Additional info:

Flutter 3.27.2

@EArminjon EArminjon added the bug Something isn't working label Jan 30, 2025
@wanzha
Copy link

wanzha commented Feb 26, 2025

I have also encountered the same problem. When will the branch that solves this problem take effect?

@EArminjon
Copy link
Contributor Author

You can directly add the branch commit inside your pubspec.yaml instead of the official version.

@wanzha
Copy link

wanzha commented Feb 27, 2025

Image
I did it the way you said, but I still found an error.

@EArminjon
Copy link
Contributor Author

Image
I did it the way you said, but I still found an error.

Show me your pubspec.yaml, have you restart your app ?

@wanzha
Copy link

wanzha commented Feb 27, 2025

Image
I did it the way you said, but I still found an error.

Show me your pubspec.yaml, have you restart your app ?

I 've restarted the project and it's still the same. Because my HTML text contains mathematical formulas and tables, and the tables also contain mathematical formulas, the tables have row merging or column merging. And I found that the error message of the flutter_html_fork plug-in is in the error message, which should be caused by the problem of flutter_html_fork.

Image

Image

@wanzha
Copy link

wanzha commented Feb 27, 2025

Image

@EArminjon
Copy link
Contributor Author

EArminjon commented Feb 27, 2025

Please use commit (more secure, else if I force push i can hack you) and put it inside direct project dependencies (not dependency_override, as this section is used to override package used by your dependencies, as you override a dependencies it will not work) :

dependencies:
  flutter_html:
    git:
      url: https://github.com/Sub6Resources/flutter_html.git
      ref: ecbeafaee8d6fd40bf9dc60664de6c3b61a7a7b2

@wanzha
Copy link

wanzha commented Feb 27, 2025

Please use commit (more secure, else if I force push i can hack you) and put it inside direct project dependencies (not dependency_override, as this section is used to override package used by your dependencies, as you override a dependencies it will not work) :

dependencies:
flutter_html:
git:
url: https://github.com/Sub6Resources/flutter_html.git
ref: ecbeafa

Image
I wrote it in "dependency_override" because of this situation

@EArminjon
Copy link
Contributor Author

EArminjon commented Feb 27, 2025

Then use both dependencies & dependency_override with the trick git-url-ref.

@wanzha
Copy link

wanzha commented Feb 27, 2025

I don't understand how to do this, can you give me an example?

Then use both dependencies & dependency_override with the trick git-url-ref.

@EArminjon
Copy link
Contributor Author

dependencies:
  flutter_html:
    git:
      url: https://github.com/Sub6Resources/flutter_html.git
      ref: ecbeafaee8d6fd40bf9dc60664de6c3b61a7a7b2

dependency_override:
  flutter_html:
    git:
      url: https://github.com/Sub6Resources/flutter_html.git
      ref: ecbeafaee8d6fd40bf9dc60664de6c3b61a7a7b2

@wanzha
Copy link

wanzha commented Feb 27, 2025

Image
I did it the way you said, but I still found an error.

Show me your pubspec.yaml, have you restart your app ?

I 've restarted the project and it's still the same. Because my HTML text contains mathematical formulas and tables, and the tables also contain mathematical formulas, the tables have row merging or column merging. And I found that the error message of the flutter_html_fork plug-in is in the error message, which should be caused by the problem of flutter_html_fork.

Image

Image

Still the same,

@EArminjon
Copy link
Contributor Author

flutter_html and flutter_math(_fork) are different packages. This PR can't fix flutter_math.

@wanzha
Copy link

wanzha commented Feb 27, 2025

Yes, this is a problem with the math package

@wanzha
Copy link

wanzha commented Feb 27, 2025

But flutter_math(fork) is used in flutter_html, so there is no solution

@EArminjon
Copy link
Contributor Author

You can open a PR on the flutter_math repo.

@wanzha
Copy link

wanzha commented Feb 27, 2025

Can you clarify what I should do? thanks

@wanzha
Copy link

wanzha commented Feb 28, 2025

"<div class=\"qml-stem\" data-copyright=\"xkw.com-1715675253-103471685322350800-MvZBwEKzHWF0525F-00brkA-YdnrpoRNbkFAp3F07j2eMbNqXatSVxcCXhac50ZV\"><p style=\"text-align: left;\"><span style=\"font-family: 宋体;\">下列元素与集合的关系中,正确的是(</span><span style=\"font-family: 'Times New Roman';\"><span style=\"font-family: 'Times New Roman'\" qml-space-size=\"4\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style=\"font-family: 宋体;\">)</span></p><div class=\" qml-og\"><table class=\"qml-og\" style=\"width:100%\"><tr><td>A.&nbsp;<span class=\"qml-op\"><math math-svg=\"https://img.xkw.com/dksih/formula/6c4fd8e0f3da866108c212843fe16211.svg\" latex=\"\$-1\\in \\mathbf{N}\$\"><mrow><mo>−</mo><mn>1</mn><mo>∈</mo><mstyle mathvariant=\"bold\" mathsize=\"normal\"><mi>N</mi></mstyle></mrow></math></span></td><td>B.&nbsp;<span class=\"qml-op\"><math math-svg=\"https://img.xkw.com/dksih/formula/a586ce98ff4f6116210cfc30ff9f858b.svg\" latex=\"\$0\\notin \\mathrm{N}^{*}\$\"><mrow><mn>0</mn><mo>∉</mo><msup><mtext>N</mtext><mo>*</mo></msup></mrow></math></span></td><td>C.&nbsp;<span class=\"qml-op\"><math math-svg=\"https://img.xkw.com/dksih/formula/8b6fe62b421c1359584b1e744c43e01a.svg\" latex=\"\$\\sqrt{3}\\in \\mathrm{Q}\$\"><msqrt><mn>3</mn></msqrt><mo>∈</mo><mtext>Q</mtext></math></span></td><td colspan=\"1\">D.&nbsp;<span class=\"qml-op\"><math math-svg=\"https://img.xkw.com/dksih/formula/d525c6cbacbe47f80e3537c4670b5854.svg\" latex=\"\$\\frac{2}{5}\\notin \\mathrm{R}\$\"><mrow><mfrac><mn>2</mn><mn>5</mn></mfrac><mo>∉</mo><mtext>R</mtext></mrow></math></span></td></tr></table></div></div>"

You can try to run this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants