Skip to main content

Rendering MFM

MfmText renders Misskey Flavored Markdown in a native Flutter widget. Install the published package using Getting started; the copyable examples in these guides target that published API, not the development example.

A bounded rendering area​

Place this widget in the body of the Material app from Getting started. Use a Dart raw string for $[...] so Dart does not interpret $ as interpolation.

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

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


Widget build(BuildContext context) {
return const SizedBox(
width: 320,
child: MfmText(
text: r'**Hello** $[fg.color=336699 blue] $[x2 large]',
config: MfmRenderConfig(enableAnimation: false),
),
);
}
}

Inputs and display modes​

InputBehavior
textMFM source; an empty string renders nothing.
parsedNodesPreviously parsed List<MfmNode> from misskey_mfm_parser. Reuse it when rendering the same parsed content; it takes precedence over text. Declare a direct parser dependency if importing the parser in your app.
simple: trueUses the simple parser: ordinary text, mentions, hashtags, URLs and most formatting are not processed as full MFM. Unicode/custom emoji remain supported.
plain: trueAlso uses simple parsing; emoji use the normal-size rendering context. This is not a generic HTML/Markdown sanitizer.
nowrap: trueA single line with ellipsis. Give the widget a finite available width.
rootScalePositive, finite root scale (default 1.0); it affects MFM rendering, not the app's accessibility preference.
isNoteDefaults to true; changes hashtag navigation details, not the parser. See Interactions.

Supply text or parsedNodes; the constructor asserts that one exists. A parser FormatException falls back to the whole source as plain text. This is not a guarantee that every malformed input throws or is sanitized. For per-post host/emoji context, see Custom emoji.

Supported syntax​

CategoryExamples / behavior
TextBold **text**, italic *text*, strike ~~text~~, small <small>text</small>, center <center>text</center>.
NavigationURLs, [label](https://example.com), @name, #tag, and search blocks. Navigation is callback-driven.
Code and quoteInline backticks, fenced code blocks with highlighting/copy, and > quote. Quotes need bounded layout width.
EmojiUnicode emoji and :shortcode:. Server emoji need an emoji builder/resolver.
MathInline/block math is shown as monospace text, not rendered LaTeX.
Plain region<plain>...</plain> keeps its contents literal.

Function blocks​

Function familyPublished behavior
x2, x3, x4, scale, positionSize and positioning effects; advanced-MFM settings affect their application.
fg, bg, font, borderText/background color, font selection and borders. Do not assume the development example's expanded border options exist in the published package.
flip, rotateStatic transforms.
blurVisual blur that can be revealed; not a security or redaction boundary.
ruby, unixtimeRuby text and timestamp display; see the development differences on the example page.
clickableDispatches an event ID through a callback.
jelly, tada, jump, bounce, shake, twitch, spin, rainbow, sparkleAnimated/effect functions. See Animation and accessibility for disabling movement.

Unknown functions retain a literal $[name ...] wrapper while rendering their children; no unknown effect is applied. Function support is not a promise of pixel-identical output to Misskey's browser renderer.

Limitations and troubleshooting​

  • No Web support and no text selection. The output uses RichText with embedded widgets, not SelectableText.
  • Use a bounded parent, such as Expanded inside a Row, if quotes or long content overflow.
  • Missing fonts and glyphs are platform-dependent. Set text/font configuration rather than assuming identical fonts on every OS.
  • toPlainText() on a rendered span is not a reliable semantic-text export: embedded widgets and visual transformations can differ from the source. Keep the original source or define an app-specific text conversion.
  • A failed/absent custom-emoji resolver leaves a shortcode. It does not mean the MFM parser failed.

Next: Configuration · Custom emoji · API reference