flame_markdown 0.2.4+6 copy "flame_markdown: ^0.2.4+6" to clipboard
flame_markdown: ^0.2.4+6 copied to clipboard

Markdown support for the Flame game engine, bridging the markdown package into Flame's text rendering pipeline.

example/lib/main.dart

import 'dart:async';

import 'package:flame/components.dart';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'package:flame/text.dart';
import 'package:flame_markdown/custom_attribute_syntax.dart';
import 'package:flame_markdown/flame_markdown.dart';
import 'package:flutter/widgets.dart' hide Animation;
import 'package:markdown/markdown.dart';

void main() {
  runApp(GameWidget(game: MarkdownGame()));
}

/// This example game showcases the use of the FlameMarkdown package
/// to render rich-text components using a simple markdown syntax.
class MarkdownGame extends FlameGame {
  @override
  Future<void> onLoad() async {
    final markdown = await Flame.assets.readFile('fire_and_ice.md');
    await add(
      TextElementComponent.fromDocument(
        document: FlameMarkdown.toDocument(
          markdown,
          document: Document(
            encodeHtml: false,
            inlineSyntaxes: [
              StrikethroughSyntax(),
              CustomAttributeSyntax(),
            ],
          ),
        ),
        style: DocumentStyle(
          padding: const EdgeInsets.all(16),
          customStyles: {
            'author': InlineTextStyle(
              color: const Color(0xFF888888),
              fontSize: 16,
              fontStyle: FontStyle.italic,
            ),
          },
        ),
        size: size,
      ),
    );
    await super.onLoad();
  }
}
3
likes
160
points
18
downloads

Publisher

verified publisherflame-engine.org

Weekly Downloads

Markdown support for the Flame game engine, bridging the markdown package into Flame's text rendering pipeline.

Repository (GitHub)
View/report issues
Contributing

Topics

#flame #markdown

Documentation

API reference

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

MIT (license)

Dependencies

flame, flutter, markdown

More

Packages that depend on flame_markdown