Skip to content

Conversation

@7576457
Copy link
Contributor

@7576457 7576457 commented Jan 25, 2026

Description

The flutter_markdown package is officially deprecated and has been replaced by flutter_markdown_plus. In this PR, I updated the old package and also added flutter_markdown_plus_latex.

For the ft.Markdown component, two new attributes are now available:

  • latex_style: accepts an ft.TextStyle object.
  • latex_scale_factor: accepts a floating-point number.

Test Code

import flet as ft

markdown = """
# Flet Markdown & LaTeX Demo

**Markdown rendering** _with_ selectable text and **LaTeX math formulas**.

- [Flet website](https://docs.flet.dev)
- https://github.com/flet-dev/flet

## Styling

Style text as _italic_, __bold__, ~~strikethrough~~, or `inline code`.

- Use bulleted lists
- To better clarify
- Your points

## Math

Inline formula:
$E = mc^2$

Block formula:
$$
P + \\frac{1}{2} \\rho v^2 + \\rho g h = \\text{constant}
$$

$$
\\int_0^1 x^2 , dx = \\frac{1}{3}
$$

"""


def main(page: ft.Page):
    page.scroll = ft.ScrollMode.AUTO
    page.add(
        ft.Markdown(
            value=markdown,
            selectable=True,
            extension_set=ft.MarkdownExtensionSet.GITHUB_WEB,
            code_theme=ft.MarkdownCodeTheme.ATOM_ONE_DARK,
            latex_style=ft.TextStyle(color="purple"),
            latex_scale_factor=1.2,
        )
    )


ft.run(main)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

image

Summary by Sourcery

Add LaTeX rendering support to the Markdown control and migrate to the new markdown package.

New Features:

  • Support rendering LaTeX formulas in the Markdown control, including custom text style and scale factor options.

Enhancements:

  • Replace the deprecated flutter_markdown dependency with flutter_markdown_plus and integrate its LaTeX extension package for markdown processing.

import '../utils/numbers.dart';
import '../utils/uri.dart';
import 'base_controls.dart';
import 'highlight_view.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Individual imports were replaced with import 'package:flet/flet.dart';.
For consistency, use individual imports instead of import "with everything".

@FeodorFitsner
Copy link
Contributor

Great PR! Replacing deprecated package and LaTeX support is a great plus.

@yunguangli
Copy link

yunguangli commented Jan 26, 2026

Awesome, I have been waiting for LaTex support. An can this LaTex mark down can be integrated with Canvas Text too? It would be great for making educational apps.

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

Successfully merging this pull request may close these issues.

3 participants