Skip to content

Flutter_markdown: add scroll view to markdown table #129052

Closed
flutter/packages
#6983

Description

@shuotwang

Is there an existing issue for this?

Use case

As the screen shot shows, if I have a very wide table, the contents are too narrow to read. It would be good if I can pan this table around with a much more human-readable column width.

The reason why I do not wrap the whole Markdown widget into a scrollable widget is that it will cause bad experience for other contents, for example, if text content is also scrollable, I need to pan around for each lone text line. It would be good if only large contents like tables and code blocks have the scroll behavior.

截屏2023-06-16 下午6 07 14

Proposal

the Table widget inside markdown builder function could be wrapped with a scrollable widget just like how it's done with code blocks, and provide the block constraints settings. Or, the constraints could be just the constraints of its parent widget. If the size of table (probably together with a minimum tableColumnWidth setting) exceeds the constrains, scroll gesture is enabled.

Activity

  1. added
    in triagePresently being triaged by the triage team
    c: new featureNothing broken; request for a new capability
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Jun 19, 2023
  2. added
    P3Issues that are less important to the Flutter project
    on Jun 20, 2023
  3. tylerjvollick commented on Apr 23, 2024

    @tylerjvollick

    Any updates on this? I'm facing the same issue with markdown tables we're trying to render with too many columns for the given horizontal space.

  4. phong010198 commented on Jun 21, 2024

    @phong010198

    I'm facing the same issue. Need horizontal scroll when using FixedColumnWidth

    styleSheet: MarkdownStyleSheet(
      tableColumnWidth: FixedColumnWidth(value),
    ),

    Edit: Temporary solution
    Download the flutter_markdown package and import to project locally.
    Open builder.dart, find the part bellow

          } else if (tag == 'table') {
            child = Table(
              defaultColumnWidth: styleSheet.tableColumnWidth!,
              defaultVerticalAlignment: styleSheet.tableVerticalAlignment,
              border: styleSheet.tableBorder,
              children: _tables.removeLast().rows,
            );
          } else if (tag == 'blockquote') {

    Wrap Table with SingleChildScrollView, scrollDirection: Axis.horizontal, and make sure to set tableColumnWidth: FixedColumnWidth(value) as my code above.

  5. Bazni commented on Jun 21, 2024

    @Bazni

    Hey 👋,

    Do you have any update or workaround on this?

  6. Bazni commented on Jun 25, 2024

    @Bazni

    The fix works well. Is a PR on going or should I try opening one?

  7. github-actions commented on Jul 13, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: flutter_markdownflutter/packages flutter_markdownpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions